Migrate from R Markdown
If you decide to migrate from R Markdown, here are some tips.
Moving over R Markdown files
Quarto is designed to be highly compatible with existing R Markdown documents
- You should generally be able to use Quarto to render any existing
.Rmd
document without changes. - Changing a
.Rmd
file to.qmd
forces it into a Quarto document.
If you run into any errors, go into the file to see what occurred.
Code chunk options
One important difference between R Markdown documents and Quarto documents is that in Quarto chunk options are typically included in “hashpipes” at the top of code chunks rather than within the line that begins the chunk:
```{r, echo = FALSE, fig-cap = "Air Quality"}
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess", se = FALSE)
```
```{r}
#| echo: false
#| fig-cap: "Air Quality"
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess", se = FALSE)
```
In the newest version of knitr (v1.40), use the function convert_chunk_header()
to convert the old in-header chunk options to the new in-body chunk options.
# convert to Quarto doc with in-body chunk options
::convert_chunk_header("to-convert.Rmd", "converted.qmd")
knitr# convert to .Rmd doc with in-body chunk options
::convert_chunk_header("to-convert.Rmd", "converted.Rmd") knitr
This will result in the following files: