Use of R Markdown to generate commented notebooks with R code and figures
Markdown is simple language syntax for text formatting (so as 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 new R Markdown file (File > New File > R Markdown...). This will open new file (with *.Rmd extension) with template to fill and few advises how to prepare R Markdown file. After you finish the text, click on Knit button (either Knit PDF, Knit HTML or Knit Word) to create requested file format. Note that for successful knitting of pdf files, you need to install complete TeX installation.
Few online sources to learn 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.