If you've ever needed to create a document — Word, PDF, HTML or even slides — that combines text with R output, graphics or code, you should check out R Markdown (from the good folks at RStudio). From just one file, you can easily create output like this (from the Tufte Handout template):
If you can write R code, you should find R Markdown pretty straightforward: you just create a text file with the words you want to include, with some simple markup for formatting, like *italics* and **bold**. (There is also syntax for more complex elements like lists and equations. Insert R graphics or output simply by including the corresponding R code chunk in your document, surrounded by ```{r} <your code> ```. You can even insert formatted tables of data generated in R, or even include interactive elements from Shiny.
From this file, you can "render" the output in PDF, Word, HTML or many other formats using the rmarkdown package in R. If you're using RStudio, there's a nice user interface (the New R Markdown dialog) that automates this process for you.
If you're used Markdown before, you'll find all of this very easy. R Markdown is very similar to most other Markdown implementations, and there's a handy R Markdown Cheat Sheet that includes all of the syntax. (Side note: if do you use multiple flavours of Markdown, it's good to see that a Markdown standard is emerging to unify them together.)
For more information about R Markdown, check out the website below for everything you need.
RStudio: R Markdown — Dynamic Documents for R
Comments