R Markdown provides an authoring framework for data science in R. With a single R Markdown file, you can not only write, save, and execute your code but also communicate your process and results with an audience using high-quality, reproducible output formats.
Edit me

Framing

R Markdown builds off tools already available in R and RStudio to provide an integrated environment for processing, coding, and communicating. An R Markdown file can include text, chunks of code, images, links, figures, and tables. While you’re working in your RStudio environment, your file operates similarly to a normal R script (a .R file) - you can write, edit, and evaluate code to work with your data. At any point, you can “knit” your file. Knitting runs, evaluates, and compiles your R Markdown file into your desired output (e.g., HTML, PDF) to create a single document that includes all the components of your written file plus the results. This knit file is ready for high-quality scientific communication with any audience. If you’ve ever seen nice examples of R code and output online, it was probably made using R Markdown.

Why should I use R Markdown?

You should use R Markdown if…

  • You already work in R or RStudio and would like some additional tools at your disposal
  • You value reproducible output
  • You would like to be able to share your work with people who are less familiar with R (or coding more generally)
  • R Markdown combines the data wrangling and analytic tools of R with high-class scientific communication. It can become your one-stop-shop for sharing your data science.

Start with the 1-minute overview video to get an idea of what R Markdown can be used for, then jump into the first online book tutorial listed. More advanced users may wish to go straight to the longer, more detailed online book for help with more complex topics. All users can refer to the cheat sheet for quick answers.

Videos

Online tutorials:

These online book/blog tutorials provide comprehensive guides on how to use R Markdown. Their clear chapter breakdowns also make it easy to find an answer to a specific question, or brush up on one skill at a time. The best part? These were all made using R Markdown, so they provide great examples of one thing you can do with this tool!

  • R Markdown from RStudio is an online book that contains lessons on R Markdown basics, specific output formats, in-line and chunk code, tables, interactive websites, presentations, using multiple coding languages, and more. It’s perfect for someone looking for a comprehensive (yet still quite succinct) tutorial on using R markdown

  • R Markdown: The Definitive Guide is a longer, more detailed online book about everything R markdown is very thorough. The authors suggest using it as a “reference” rather than “textbook” because of the amount of information contained. The How to Read this Book section in the preface demonstrates how users with different questions or needs might navigate the book.

  • The Communication section from the R for Data Science online book includes several chapters on R markdown (the tidyverse’s preferred method for statistical and scientific communication).

Papers

Additional resources

  • This cheat sheet is a one-stop-shop for a very quick introduction to R Markdown. It’s also great for quick answers to questions about common tasks.

  • This online code from GitHub Gist provides an example/walkthrough of using R Markdown.