Sweave is a function in the statistical programming language R that enables integration of R code into LaTeX or LyX documents. The purpose is "to create dynamic reports, which can be updated automatically if data or analysis change".
The data analysis is performed at the moment of writing the report, or more exactly, at the moment of compiling the Sweave code with Sweave (i.e., essentially with R) and subsequently with LaTeX. This can facilitate the creation of up-to-date reports for the author.
Because the Sweave files together with any external R files that might be sourced from them and the data files contain all the information necessary to trace back all steps of the data analyses, Sweave also has the potential to make research more transparent and reproducible to others. However, this is only the case to the extent that the author makes the data and the R and Sweave code available. If the author only publishes the resulting PDF document or printed versions thereof, a report created using Sweave is no more transparent or reproducible than the same report created with other statistical and text preparation software.
- Literate Programming
- Reproducible research
- The R Programming wikibook
- knitr (an alternative to Sweave in R)
- Leisch F (2002). "Sweave, Part I: Mixing R and LaTeX: A short introduction to the Sweave file format and corresponding R functions". R News 2 (3): 28–31. Retrieved 22 January 2012.
- Pineda-Krch, Mario (17 January 2011). "The Joy of Sweave – A Beginner’s Guide to Reproducible Research with Sweave" (in English). Retrieved 22 Jan 2012.