Processing .Rnw files through Sweave ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To process the file r-exs1.Rnw, place the files r-exs1.Rnw and wrapper1.Rnw in your intended working directory, start up R, and type in Sweave("r-exs1") Sweave("wrapper1") If all goes well (it should, providing you do not tinker too inexpertly with the file contents!), this generates latex files r-exs1.tex and wrapper1.tex, and graphs that will be included when the wrapper file wrapper1.tex (which accesses r-exs1.tex as an include file), is processed through latex or pdflatex. The files r-exs2.Rnw, r-exs3.Rnw and r-exs4.Rnw can be similarly processed using the R Sweave() function. Wrapper files are readily created by changing the \include{r-exs1} as required in wrapper1.Rnw, or directly in wrapper1.tex. [Processing wrapper1.Rnw through Sweave() added a requisite \usepackage command, with the correct path for the setup on the computer system that handled the processing.] The R code from r-exs1.Rnw (also in r-exs1.tex) is in the file r-exs1.R, in the scripts subdirectory You can obtain this code file by typing, from within R Stangle("r-exs1.Rnw") What is Sweave? ~~~~~~~~~~~~~~ To quote from the help file for Sweave() "'Sweave' provides a flexible framework for mixing text and S code for automatic report generation. The basic idea is to replace the S code with its output, such that the final document only contains the text and the output of the statistical anlysis. [It allows] automatic generation of reports by mixing word processing markup (like latex) and S code. The S code gets replaced by its output (text or graphs) in the final markup file. This allows to re-generate a report if the input data change and documents the code to reproduce the analysis in the same file that also produces the report." The Sweave syntax is based on the Noweb literate syntax. Reference: Friedrich Leisch: Sweave User Manual, 2002 John Maindonald July 20, 2006.