rnw2pdf {stationery} | R Documentation |
Convert (Sweave & compile) an Rnw or lyx file to PDF
Description
Documents saved with suffix ".lyx" or ".Rnw" will be converted. Note it is very important to specify the engine for the code chunks correctly, this can be either "Sweave" or "knitr".
Usage
rnw2pdf(
fn = NULL,
wd = NULL,
...,
engine = "knitr",
purl = TRUE,
tangle = purl,
backup = TRUE,
clean = TRUE,
quiet = TRUE,
verbose = !quiet,
envir = parent.frame(),
encoding = getOption("encoding")
)
Arguments
fn |
One or more file names, should end in either ".Rnw" or ".lyx" |
wd |
Directory in which the file to be converted exists. Leave NULL default if is in current working directory. |
... |
Other parameters, not used at the moment. |
engine |
"knitr" or "Sweave" |
purl |
Default TRUE. Synonym of tangle: extract R code chunks |
tangle |
Same as purl, both parameters have same result |
backup |
Default TRUE. Will create backup copies of pdf, R, Rnw
files before replacing them. Uses |
clean |
Default TRUE. Remove intermediate LaTeX files when using texi2pdf |
quiet |
Default = TRUE. No output unless an error occurs.
Antonym for |
verbose |
Default = |
envir |
environment for evaluation, see |
encoding |
character encoding, defaults from user options |
Value
names of pdf output files
Author(s)
Paul Johnson <pauljohn@ku.edu>
Examples
tdir <- tempdir()
fmt <- "rnw2pdf-guide-sweave"
dirout <- initWriteup(fmt, dir = file.path(tdir, fmt))
print(dirout)
list.files(dirout)
of1 <- try(rnw2pdf("skeleton.Rnw", engine = "Sweave", wd = dirout, backup = TRUE))
if(inherits(of1, "try-error")){
MESSG <- paste("Compiling the markdown file failed, perhaps",
"there is an R or LaTeX error.",
"Run again with parameters verbose=TRUE",
"and clean=FALSE")
print(MESSG)
} else {
## Check the result file:
MESSG <- paste("Check the directory", dirout, "for results.")
print(MESSG)
list.files(dirout)
if(interactive() && file.exists(of1)) {
browseURL(of1)
}
}
unlink(dirout)