8 R Markdown
R Markdown is a file format that combines R code with Markdown text. Thus, a Markdown file typically has three components:
- YAML metadata
- R Chunks
- Markdown text
Rendering an R Markdown file is completed in two steps:
- run R code
- convert to desired output
After running the R code, the first step converts the R Markdown document into a Markdown document.
Despite the name, R Markdown files have suport for a number of other languages including Python and Julia.
8.1 Code
8.1.1 Chunks
Most R code in R Markdown files will be executed in a code chunk. Code chunks begin and end with backticks.
::: {.cell}
```{.r .cell-code}
1 + 1
```
::: {.cell-output .cell-output-stdout}
```
[1] 2
```
::: :::
8.1.2 Inline
R code can be included inline as well as through code chunks. For example, there are