| R2Sweave {tutoR} | R Documentation |
Translate R code into a Sweave (then Latex) document.
R2Sweave(func = NULL, infile = NULL)
func |
Any R function to form the basis of the document. |
infile |
Alternatively, a file containing all R-code to be included. |
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.
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.
Mark Fielding, Andrew Robinson <A.Robinson@ms.unimelb.edu.au>
## 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)