R2Sweave {tutoR}R Documentation

Sweave document creation

Description

Translate R code into a Sweave (then Latex) document.

Usage

R2Sweave(func = NULL, infile = NULL)

Arguments

func Any R function to form the basis of the document.
infile Alternatively, a file containing all R-code to be included.

Details

Separate blocks of code are identified by 2 or more blank lines between them. A line of text starting with ### is thereafter included as purely Latex. Otherwise, a single or double #, or text, is taken to be R-code.

Note

A suitable input file should be, file.R, or file.R. An outfile will be chosen and suitably indexed, Sw--.Rnw or Sw--.rnw. A sdingle figure will be included, to which appropriate code may later be placed, or reproduced for further figures.

Author(s)

Mark Fielding, Andrew Robinson <A.Robinson@ms.unimelb.edu.au>

See Also

Sweave, RweaveLatex

Examples

## Not run: 

myfunc <- function(x, y) {
        if(y < x) {temp <- x; x <- y; y <- temp }
        ANSWER <- 1
        for(i in 0:(y-x)) ANSWER <- ANSWER * (y-i)
        return(ANSWER)
}

R2Sweave(myfunc)

write("myfunc <-", "myfunc.R")
write(deparse(myfunc), append=TRUE, "myfunc.R")
unlink(\"myfunc\")

R2Sweave("myfunc.R")

## End(Not run)

[Package tutoR version 0.3.2 Index]