Sweave             package:utils             R Documentation(latin1)

_A_u_t_o_m_a_t_i_c _G_e_n_e_r_a_t_i_o_n _o_f _R_e_p_o_r_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     '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.

_U_s_a_g_e:

     Sweave(file, driver = RweaveLatex(),
            syntax = getOption("SweaveSyntax"), ...)

     Stangle(file, driver = Rtangle(),
             syntax = getOption("SweaveSyntax"), ...)

_A_r_g_u_m_e_n_t_s:

    file: Name of Sweave source file.

  driver: The actual workhorse, see details below.

  syntax: An object of class 'SweaveSyntax' or a character string with
          its name. The default installation provides
          'SweaveSyntaxNoweb' and 'SweaveSyntaxLatex'.

     ...: Further arguments passed to the driver's setup function.

_D_e_t_a_i_l_s:

     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.

     'Sweave' combines the documentation and code chunks together (or
     their output) into a single document.  'Stangle' extracts only the
     code from the Sweave file creating a valid S source file (that can
     be run using 'source').  Code inside '\Sexpr{}' statements is
     ignored by 'Stangle'.

     'Stangle' is just a frontend to 'Sweave' using a simple driver by
     default, which discards the documentation and concatenates all
     code chunks the current S engine understands.

_H_o_o_k _F_u_n_c_t_i_o_n_s:

     Before each code chunk is evaluated, a number of hook functions
     can be executed.  If 'getOption("SweaveHooks")' is set, it is
     taken to be a collection of hook functions. For each logical
     option of a code chunk ('echo', 'print', ...) a hook can be
     specified, which is executed if and only if the respective option
     is 'TRUE'. Hooks must be named elements of the list returned by
     'getOption("SweaveHooks")' and be functions taking no arguments. 
     E.g., if option '"SweaveHooks"' is defined as 'list(fig = foo)',
     and 'foo' is a function, then it would be executed before the code
     in each figure chunk. This is especially useful to set defaults
     for the graphical parameters in a series of figure chunks.

     Note that the user is free to define new Sweave options and
     associate arbitrary hooks with them.  E.g., one could define a
     hook function for option 'clean' that removes all objects in the
     global environment.  Then all code chunks with 'clean = TRUE'
     would start operating on an empty workspace.

_S_y_n_t_a_x _D_e_f_i_n_i_t_i_o_n:

     Sweave allows a very 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 details.

_A_u_t_h_o_r(_s):

     Friedrich Leisch

_R_e_f_e_r_e_n_c_e_s:

     Friedrich Leisch: Dynamic generation of statistical reports using
     literate data analysis. In W. Haerdle and B. Roenz, editors,
     Compstat 2002 - Proceedings in Computational Statistics, pages
     575-580. Physika Verlag, Heidelberg, Germany, 2002. ISBN
     3-7908-1517-9.

     Friedrich Leisch: Sweave User Manual, 2008
      <URL: http://www.stat.uni-muenchen.de/~leisch/Sweave>

_S_e_e _A_l_s_o:

     'RweaveLatex', 'Rtangle'

_E_x_a_m_p_l_e_s:

     testfile <- system.file("Sweave", "Sweave-test-1.Rnw", package = "utils")

     ## enforce par(ask=FALSE)
     options(device.ask.default=FALSE)

     ## create a LaTeX file
     Sweave(testfile)

     ## This can be compiled to PDF by
     ## Not run: tools::texi2dvi("Sweave-test-1.tex", pdf=TRUE)
     ## or outside R by
     ## R CMD texi2dvi Sweave-test-1.tex
     ## which sets the appropriate TEXINPUTS path.

     ## create an S source file from the code chunks
     Stangle(testfile)
     ## which can be sourced, e.g.
     source("Sweave-test-1.R")

