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.

Try it out!

rstd.io/quarto-blog-exercise-repo
Launch RStudio Cloud rstd.io/quarto-blog-exercise-cloud

In the exercise blog:

  • Render the .Rmd file in the rmarkdown-post folder.

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
knitr::convert_chunk_header("to-convert.Rmd", "converted.qmd")
# convert to .Rmd doc with in-body chunk options
knitr::convert_chunk_header("to-convert.Rmd", "converted.Rmd") 

This will result in the following files:

Before conversion

After conversion

Try it out!

rstd.io/quarto-blog-exercise-repo
Launch RStudio Cloud rstd.io/quarto-blog-exercise-cloud

In the exercise blog:

  • Convert the .Rmd file in rmarkdown-post to .qmd, and move to a new post/my-new-qmd-post folder.