Sweave                 package:tools                 R Documentation

_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 to
     re-generate a report 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: Sweave User Manual, 2002
     <URL: http://www.ci.tuwien.ac.at/~leisch/Sweave>

     Friedrich Leisch: Dynamic generation of statistical reports using
     literate data analysis. Report 69, SFB ``Adaptive Information
     Systems and Modelling in Economics and Management Science'', March
     2002.

_S_e_e _A_l_s_o:

     `RweaveLatex', `Rtangle'

_E_x_a_m_p_l_e_s:

     testfile <- file.path(.path.package("tools"),
                           "Sweave", "Sweave-test-1.Rnw")

     ## create a LaTeX file
     Sweave(testfile)

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

