Sweave for Automatic Report Generation

Sweave is a utility included in R that allows one to create dynamic reports in latex capturing output from embedded S or R code that is run "on the fly".

Embedded R code can optionally be extracted into R source files using Rtangle.
See the help topic [?Sweave or help(Sweave)]

Friedrich Leisch. "Sweave: Dynamic generation of statistical reports using literate data analysis." In Wolfgang Härdle and Bernd Rönz, editors, Compstat 2002 - Proceedings in Computational Statistics, pages 575-580. Physica Verlag, Heidelberg, 2002. ISBN 3-7908-1517-9.

Useful links:

  • Sweave home page by Friedrich Leisch, with Sweave manual, FAQ, examples, and more.
  • MikTeX is a version of latex for Windows.
  • WinEdt is a powerful editor for latex in Windows that works well with MikTeX.
Reports are created by Sweave+LaTeX:

Sweave file --> Sweave (in R) --> .tex output file --> LaTeX --> dvi, pdf, or ps report

Example 1a: Preparing an assignment.

This example provides a very simple template for preparing an assignment using Sweave with latex-style syntax.

Example 1b: Preparing an assignment using "noweb style" syntax.