This appendix provided an introduction to R Markdown (Allaire et al., 2021), which implements a notion of literate programming (Knuth, 1984) in R. Essentially, R Markdown allows mixing text and code in an input document (an
.Rmd file) and merges (or “knits”) the formatted text and evaluated code results in a separate output document (e.g., an
A typical R Markdown document consists of three distinct parts:
- A header for setting global document options;
- Text that may contain headings, paragraphs, and itemized lists; and
- Code chunks that contain and evaluate R code.
Fortunately, the range of commands required to benefit from R Markdown is very limited. For instance, the commands in the help file Help > Markdown Quick Reference of RStudio provide a good start for creating beautiful and functional documents. Beyond these basics, the R Markdown Cheatsheet — also available in RStudio by selecting Help > Cheatsheets > R Markdown Cheatsheet — provides a more comprehensive overview of R Markdown functionality and commands:
Finally, the following Section F.5 points to resources that provide information on more advanced uses of R Markdown.