RMarkdown/Quarto Tips and Tricks

Author

Indrajeet Patil

Modified

November 17, 2024

Keywords

r, rmarkdown, quarto, literate programming

This document provides a collection of my tweets containing tips and tricks related to RMarkdown, and its successor, Quarto. Although the document was originally meant for personal use, I’m hoping that others might also find it useful.

If you’re reading this on GitHub README, you can read the tweets on this webpage: https://indrajeetpatil.github.io/RmarkdownTips/

Tip

Source code for this document can be found on GitHub: https://github.com/IndrajeetPatil/RmarkdownTips

Ackowledgments

Most of these tips are from Yihui Xie’s books and I would highly recommend that you check them out. Except for the one about {knitr}, all other books are available online for free.

I would especially like to thank Christophe Dervieux, who has patiently answered my questions and queries on Twitter, GitHub, and StackOverflow. His kindness and patience is boundless, not to mention his knowledge of the markdown-universe.

Tweets with tips and tricks

Be patient

It might take a few seconds before the tweets are rendered on the webpage.
Apologies in advance for the delays.

Embed one chunk in another chunk

Render R Markdown with rmarkdown::render()

Child documents

Opening linked documents in a new tab

Line numbers for code blocks

Knitting with Infinite Moon Reader

Multi-column layout with Pandoc’s fenced div

Side-by-side plots in code chunk

Side-by-side tables in code chunk

Skipping evaluation of specific lines of code

Parametrized reports

Inline formatting

Using verbatim engine for teaching

Custom CSS

Additional templates in other packages

Tufte-style margin content

Multiple output formats

Changing graphical devices

Additional arguments to graphical devices

Include appendix after bibliography

Confusion between eval, echo, include

Set the document title dynamically

In-body syntax for chunk options

Option aliases

Reducing size with {prettydoc}

Cross-referencing with {bookdown}

Preserving spaces

Also see Yihui’s much simpler solution in the thread

Using YAML pipe operator ( | )

Formatting/styling code

Bootstrap themes

Description lists in HTML vignettes

Code highlighting styles

Shiny Documents

Keyboard short-cut to split chunk

Interactive dashboards

Data frame printing

Xaringan to Quarto conversion