cm006 2015-09-24 Thursday overview

Q and A from 2014

R Markdown is not the only way to get a pretty report. You can also get one from an R script.

  • When editing a .R file, RStudio offers a button for this is the spiral bound notebook icon, near where the “Knit HTML” button appears for .Rmd. Click and you get “Compile Notebook”.
  • Under the hood, you are using a function called spin() from the knitr package.
  • Jenny’s ggplot2 tutorial includes alot of Markdown that was made this way, i.e. from .R not .Rmd
    • look at source vs. rendered to get a feel for this
    • download the source and render yourself!
  • Basically, the special comment prefix #' becomes very important
  • R Markdown: prose is queen, R code is sequestered in special chunks
  • R script: code is queen, prose is sequestered in special comments
  • You can get virtually same HTML report either way. Which to choose? Depends whether the report is primary goal (choose .Rmd) or a by-product (choose .R).

I passed around hard copies of these 5 books (note: some links to eBooks and repositories are tuned to UBC users):