Sweave
Sweave is a function that was written by Friedrich Leisch for the statistical software R and is implemented there in the utils package . Sweave creates a dynamic connection between R and LaTeX . LaTeX is a software system for using the text typesetting TeX . B. scientific texts can be written.
Sweave enables the linking of R-Code and LaTeX commands. During the runtime of the R program, the selected R outputs are combined with the LaTeX commands to form a LaTeX file.
Statistical programs such as R are often used when evaluating data. This can result in tables, graphics and statistics that are to be used in a publication. If a large number of analysis results have arisen, then it is very tedious to insert the desired analysis data (possibly by hand) into the document to be created. With Sweave, the analysis results created in R can be automatically transferred to the LaTeX document.
Sweave can be briefly referred to as a “report generator”. The final LaTeX document contains the running text as well as R-code and selected R-editions. The instructions and outputs that are ultimately to be included in the LaTeX document can be selected by specifying various options. The document can therefore be easily updated if, for example, data should be changed or other calculations should be carried out.
The advantage of Sweave is not only the automatic insertion of analysis results in a LaTeX document, but also the ease with which the target document can be changed when calculations or data are changed.
By publishing program code, the procedure for calculations carried out, statistics and graphics etc. can be better understood by third parties. This means that the results can be easily reproduced and checked, provided the data are available.
Procedure with Sweave
First, a LaTeX file is created in which
<< OPTIONS >> =
R statements
@
R commands can be inserted. The specification of various options enables the R output to be controlled within the LaTeX document.
The file can be converted into a file that can be translated by LaTeX within R with the command Sweave (.). The R instructions and the R output are converted into LaTeX instructions. The file created in this way can be processed further with the help of various LaTeX compilers. So z. For example, a PDF file can be created with PdfTeX .
literature
- Friedrich Leisch : Sweave: Dynamic generation of statistical reports. In: W. Härdle and B. Rönz, eds., Compstat 2002 - Proceedings in Computational Statistics, pages 575-580. Physika Verlag, Heidelberg, 2002. URL http://www.statistik.lmu.de/~leisch/Sweave/ . ISBN 3-7908-1517-9 .
- Friedrich Leisch : Sweave, Part I: Mixing R and LaTeX. R News, 2 (3), 2002, pages 28–31 URL http://cran.r-project.org/doc/Rnews/
- Friedrich Leisch : Sweave, Part II: Package Vignettes. R News, 3 (2), 2003, pages 21-24 URL
Web links
- Source of information for Sweave Homepage of Prof. Dr. Friedrich Leisch