Use of R Markdown to generate commented notebooks with R code and figures
Markdown is a simple language syntax for text formatting (so that it looks good and can be exported into pdf/html/Word or other formats). R Markdown combines R scripts/figures/outputs with Markdown language and offers a way to create annotated notebooks directly in RStudio.
How it works: in RStudio, open a new R Markdown file (File > New File > R Markdown...). This will open a new file (with *.Rmd extension) with a template to fill, and with a few suggestions on how to prepare an R Markdown file. After you finish the text, click on Knit button (either Knit PDF, Knit HTML or Knit Word) to create the requested file format. Note that for successful knitting of pdf files, you need to install complete TeX installation.
Few online sources to learn the basics of Markdown:
Below is Markdown version (random-walk-vectorized.Rmd
) of the commented script Vectorized version of random walk script. You can also download the knitted pdf file and Word file version.
Another option is to use R Markdown to create simple presentations. Below is a short R Markdown file (draw-stairs.rmd) creating slides showing how to Draw stairs (to heaven). This R Markdown script can create either pdf presentation or can be published using HTML, e.g. again on RPubs.