EVOLUTION-MANAGER
Edit File: Sweave.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Automatic Generation of Reports</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for Sweave {utils}"><tr><td>Sweave {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Automatic Generation of Reports</h2> <h3>Description</h3> <p><code>Sweave</code> provides a flexible framework for mixing text and R/S code for automatic report generation. The basic idea is to replace the code with its output, such that the final document only contains the text and the output of the statistical analysis: however, the source code can also be included. </p> <h3>Usage</h3> <pre> Sweave(file, driver = RweaveLatex(), syntax = getOption("SweaveSyntax"), encoding = "", ...) Stangle(file, driver = Rtangle(), syntax = getOption("SweaveSyntax"), encoding = "", ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>file</code></td> <td> <p>Path to Sweave source file. Note that this can be supplied without the extension, but the function will only proceed if there is exactly one Sweave file in the directory whose basename matches <code>file</code>.</p> </td></tr> <tr valign="top"><td><code>driver</code></td> <td> <p>the actual workhorse, (a function returning) a named <code><a href="../../base/html/list.html">list</a></code> of five functions, see ‘Details’ or the Sweave manual vignette.</p> </td></tr> <tr valign="top"><td><code>syntax</code></td> <td> <p><code>NULL</code> or an object of class <code>SweaveSyntax</code> or a character string with its name. See the section ‘Syntax Definition’.</p> </td></tr> <tr valign="top"><td><code>encoding</code></td> <td> <p>The default encoding to assume for <code>file</code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments passed to the driver's setup function: see section ‘Details’, or specifically the arguments of the <code>R...Setup()</code> function in <code><a href="RweaveLatex.html">RweaveLatex</a></code> and <code><a href="Rtangle.html">Rtangle</a></code>, respectively.</p> </td></tr> </table> <h3>Details</h3> <p>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 a report to be re-generated if the input data change and documents the code to reproduce the analysis in the same file that also produces the report. </p> <p><code>Sweave</code> combines the documentation and code chunks together (or their output) into a single document. <code>Stangle</code> extracts only the code from the Sweave file creating an S source file that can be run using <code><a href="../../base/html/source.html">source</a></code>. (Code inside <code>\Sexpr{}</code> statements is ignored by <code>Stangle</code>.) </p> <p><code>Stangle</code> is just a wrapper to <code>Sweave</code> specifying a different default driver. Alternative drivers can be used: the former CRAN package <a href="https://CRAN.R-project.org/package=cacheSweave"><span class="pkg">cacheSweave</span></a> and the Bioconductor package <span class="pkg">weaver</span> provide drivers based on the default driver <code><a href="RweaveLatex.html">RweaveLatex</a></code> which incorporate ideas of <em>caching</em> the results of computations on code chunks. </p> <p>Environment variable <span class="env">SWEAVE_OPTIONS</span> can be used to override the initial options set by the driver: it should be a comma-separated set of <code>key=value</code> items, as would be used in a <span class="samp">\SweaveOpts</span> statement in a document. </p> <p>Non-ASCII source files must contain a line of the form </p> <pre> \usepackage[foo]{inputenc}</pre> <p>(where <span class="samp">foo</span> is typically <span class="samp">latin1</span>, <span class="samp">latin2</span>, <span class="samp">utf8</span> or <span class="samp">cp1252</span> or <span class="samp">cp1250</span>) or they will give an error. Re-encoding can be turned off completely with argument <code>encoding = "bytes"</code>. </p> <h3>Syntax Definition</h3> <p>Sweave allows a flexible syntax framework for marking documentation and text chunks. The default is a noweb-style syntax, as alternative a latex-style syntax can be used. (See the user manual for further details.) </p> <p>If <code>syntax = NULL</code> (the default) then the available syntax objects are consulted in turn, and selected if their <code>extension</code> component matches (as a regexp) the file name. Objects <code>SweaveSyntaxNoweb</code> (with <code>extension = "[.][rsRS]nw$"</code>) and <code>SweaveSyntaxLatex</code> (with <code>extension = "[.][rsRS]tex$"</code>) are supplied, but users or packages can supply others with names matching the pattern <code>SweaveSyntax.*</code>. </p> <h3>Author(s)</h3> <p>Friedrich Leisch and R-core. </p> <h3>References</h3> <p>Friedrich Leisch (2002) Dynamic generation of statistical reports using literate data analysis. In W. Härdle and B. Rönz, editors, <em>Compstat 2002 - Proceedings in Computational Statistics</em>, pages 575–580. Physika Verlag, Heidelberg, Germany, ISBN 3-7908-1517-9. </p> <h3>See Also</h3> <p>‘<a href="../doc/Sweave.pdf">Sweave User Manual</a>’, a vignette in the <span class="pkg">utils</span> package. </p> <p><code><a href="RweaveLatex.html">RweaveLatex</a></code>, <code><a href="Rtangle.html">Rtangle</a></code>. </p> <p>Packages <a href="https://CRAN.R-project.org/package=cacheSweave"><span class="pkg">cacheSweave</span></a> (archived), <span class="pkg">weaver</span> (Bioconductor) and <a href="https://CRAN.R-project.org/package=SweaveListingUtils"><span class="pkg">SweaveListingUtils</span></a> (archived). </p> <p>Further Sweave drivers are in, for example, packages <a href="https://CRAN.R-project.org/package=R2HTML"><span class="pkg">R2HTML</span></a>, <a href="https://CRAN.R-project.org/package=ascii"><span class="pkg">ascii</span></a>, <a href="https://CRAN.R-project.org/package=odfWeave"><span class="pkg">odfWeave</span></a> (archived) and <a href="https://CRAN.R-project.org/package=pgfSweave"><span class="pkg">pgfSweave</span></a> (archived). </p> <p>Non-Sweave vignettes may be built with <code>tools::<a href="../../tools/html/buildVignette.html">buildVignette</a></code>. </p> <h3>Examples</h3> <pre> testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package = "utils") ## enforce par(ask = FALSE) options(device.ask.default = FALSE) ## create a LaTeX file - in the current working directory, getwd(): Sweave(testfile) ## This can be compiled to PDF by ## tools::texi2pdf("Sweave-test-1.tex") ## or outside R by ## ## R CMD texi2pdf Sweave-test-1.tex ## on Unix-alikes which sets the appropriate TEXINPUTS path. ## ## On Windows, ## Rcmd texify --pdf Sweave-test-1.tex ## if MiKTeX is available. ## create an R source file from the code chunks Stangle(testfile) ## which can be sourced, e.g. source("Sweave-test-1.R") </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>