These are a few notes taken from Roger Peng's computing club presentation on Sweave.
A few key resources can be found at this online repository of good Sweave info, including the Sweave manual.
The basic steps for creating a pdf file with Sweave are:
- create a file with the .Rnw extension (following Sweave syntax as documented in the Sweave manual.
- in R, run the command
this creates a new file called myfile.tex
- use whatever LaTeX program you use to convert the tex file to pdf.
**Typical sweave code block with some explanation of the different options**
<<blockName, echo=F, results=tex, figure=F>>
[some R code here]
- blockName = a unique name for the R code module (translates into any figure names)
- echo = show the R code in the latex file
- results = print the results of the R code in the latex file
- figure = figure included in the block
- height = specification of figure height
- eps = false
- cache = saves objects that do not need to be re-run (NB: need to have separate code chunks for computation and presentation and only works with one of the caching libraries -- cacheSweave or weaver)