Slides: bit.ly/RUGgre18
(adapted with permission from Antoine Bichat's presentation)
.md
.Markdown is a lightweight markup language with plain text formatting syntax that can be converted to many formats, including HTML.
It is completely independent from R.
The extention is typically .md
.
R Markdown is an extension of the markdown syntax that enables R code to be executed. The extention is typically .Rmd
.
Markdown is a lightweight markup language with plain text formatting syntax that can be converted to many formats, including HTML.
It is completely independent from R.
The extention is typically .md
.
R Markdown is an extension of the markdown syntax that enables R code to be executed. The extention is typically .Rmd
.
{rmarkdown} is an R package that proceses and converts .Rmd
files into a number of different formats, including HTML, PDF and Word.
.Rmd
in RStudio.Rmd
in RStudio.Rmd
.Rmd
Use the Knit
button to produce a HTML file
Shortcut: Ctrl + Shift + K
# Big title## Title### Small title_Italic_, *italic*, __bold__, **bold**, and `monospace`
# Big title## Title### Small title_Italic_, *italic*, __bold__, **bold**, and `monospace`
Italic, italic, bold, bold, and monospace
1. This is2. an ordered3. list
This is
an ordered
list
1. This is2. an ordered3. list
This is
an ordered
list
* This is * a bullet list * with indent
This is
a bullet list
1. This is2. an ordered3. list
This is
an ordered
list
* This is * a bullet list * with indent
This is
a bullet list
You can enumerate only with '1.
'; it will increment automatically
You can also use '-
' or '+
' instead of '*
'
> You can insert quotes and $\LaTeX$ expressions
You can insert quotes and LATEX expressions
> You can insert quotes and $\LaTeX$ expressions
You can insert quotes and LATEX expressions
$$ \frac{1}{n} \sum_{i=1}^n X_i $$
1nn∑i=1Xi
> You can insert quotes and $\LaTeX$ expressions
You can insert quotes and LATEX expressions
$$ \frac{1}{n} \sum_{i=1}^n X_i $$
1nn∑i=1Xi
Make an horizontal line with '***
'
Add 4 spaces at the end of your text in order to write to the next line
You can write HTML in Markdown (e.g. use '<br>
' to get a blank line)
[Antoine's personal page](https://abichat.github.io/)
[Antoine's personal page](https://abichat.github.io/)

[Antoine's personal page](https://abichat.github.io/)

It also works directly with HTML syntax:
<a href="https://abichat.github.io/">Antoine's personal page</a><img src="https://slides.yihui.name/gif/impossible-parking.gif">
```{r}x <- 4x```
```{r}x <- 4x```
[1] 4
```{r}x <- 4x```
[1] 4
To display the output of a code chunk but not the underlying R code, you specify the echo=FALSE
option
```{r, echo=FALSE}x <- 5x```
```{r}x <- 4x```
[1] 4
To display the output of a code chunk but not the underlying R code, you specify the echo=FALSE
option
```{r, echo=FALSE}x <- 5x```
To display R code without evaluating it, you specify the eval=FALSE
chunk option
```{r, eval=FALSE}x <- 5```
```{r, fig.align="center", out.width="60%"}ggplot2::qplot(Sepal.Length, Sepal.Width, data = iris)```
```{r, fig.align="center", out.width="80%", fig.asp=0.7, fig.width=4}ggplot2::qplot(Sepal.Length, Sepal.Width, data = iris)```
```{r, fig.align="center", out.width="80%", echo=FALSE}knitr::include_graphics( "https://slides.yihui.name/gif/impossible-parking.gif")```
It allows you to use the chunk options for image size.
```{r, echo=FALSE, out.width="50%", fig.show="hold", fig.align="default"}plot(iris)plot(iris, pch = 20, col = iris$Species)```
R
Python
Shell
SQL
Rcpp
Stan
JavaScript
CSS
Julia
C and Fortran
You can play with YAML option df_print
. For example, df_print: paged
:
iris ## or directly with `DT::datatable(iris)`
ABCDEFGHIJ0123456789 |
Sepal.Length <dbl> | Sepal.Width <dbl> | Petal.Length <dbl> | Petal.Width <dbl> | Species <fct> |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |
4.6 | 3.4 | 1.4 | 0.3 | setosa |
5.0 | 3.4 | 1.5 | 0.2 | setosa |
4.4 | 2.9 | 1.4 | 0.2 | setosa |
4.9 | 3.1 | 1.5 | 0.1 | setosa |
For more refined tables, you can use knitr::kable()
, xtable::xtable()
, kableExtra::kable().
Reports (analysis, etc) with text, code and results in the same place! With many possible output formats including HTML, PDF, MS Word, etc.
Notebooks (vs "Chunk Output in Console")
Slides (like this one! -- see source code)
Websites (such as the website of our R user group)
Books (e.g. my online advanced R course or even a thesis)
[WIP] {pagedown}: Paginate the HTML Output of R Markdown with CSS for Print
beamer (pdf)
powerpoint (ppt)
xaringan / remark.js (example: this presentation!)
beamer (pdf)
powerpoint (ppt)
xaringan / remark.js (example: this presentation!)
3 main reasons to make your slides with R Markdown:
beamer (pdf)
powerpoint (ppt)
xaringan / remark.js (example: this presentation!)
3 main reasons to make your slides with R Markdown:
beamer (pdf)
powerpoint (ppt)
xaringan / remark.js (example: this presentation!)
3 main reasons to make your slides with R Markdown:
Include code and results very easily
Make HTML presentations directly available online (easy to export them to PDF using "print to PDF" of Chrome)
beamer (pdf)
powerpoint (ppt)
xaringan / remark.js (example: this presentation!)
3 main reasons to make your slides with R Markdown:
Include code and results very easily
Make HTML presentations directly available online (easy to export them to PDF using "print to PDF" of Chrome)
Include fancy HTML widgets (like maps, searchable tables, interactive graphics, etc)
library(leaflet)leaflet(width = "100%") %>% setView(lng = 5.767249, lat = 45.190590, zoom = 12) %>% addTiles(options = providerTileOptions(minZoom = 2, maxZoom = 19))
Example: webpage of the Grenoble RUG
How does it work?
just multiple Rmd documents (one by page) rendered as HTML with a common navigation bar
host the static HTML pages using e.g. GitHub pages
make your own website in 20 minutes with this tutorial
You can also use {blogdown}. See the full documentation.
Every R book is now written with {bookdown}.
See many of them at https://bookdown.org/.
Again, from our side, it is just a collection of R Markdown documents.
E.g. see my advanced R course and the associated GitHub repository.
Formats in {bookdown} allows you to:
number and reference equations, tables, figures, etc
use special chunks such as theorems and proofs
special headers such as "PART" and "APPENDIX"
citations
etc
Formats in {bookdown} allows you to:
number and reference equations, tables, figures, etc
use special chunks such as theorems and proofs
special headers such as "PART" and "APPENDIX"
citations
etc
To use this in single R Markdown documents (not books), you can use formats
bookdown::html_document2()
bookdown::pdf_document2()
bookdown::word_document2()
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |