For notebooks, R Markdown, and Rhtml
, RStudio relies on Yihui Xie's knitr
package for executing code chunks and merging the results. The knitr
package can be installed via RStudio's Packages tab or with the command install.packages("knitr")
.
For LaTeX/Sweave files, the default is to use R's native Sweave driver. The knitr
package is easier to use and has more options for fine-tuning, so in the rest of this chapter we assume that
knitr
is always used. To make sure that knitr
is also used for Sweave files, go to Tools | Options | Sweave and choose knitr as Weave Rnw files. If you're working in an RStudio project, you can set this as a project option as well by navigating to Project | Project Options | Sweave. When you work with LaTeX/Sweave, you need to have a working LaTeX distribution installed. Popular distributions are TeXLive for Linux, MikTeX for Windows, and MacTeX for Mac OS X.