rmd2pdf {stationery} | R Documentation |
Convert Rmd to PDF
Description
Convert an Rmd file to PDF by Sweaveing or knitting and then compiling.
Usage
rmd2pdf(
fn = NULL,
wd = NULL,
...,
verbose = FALSE,
purl = TRUE,
tangle = purl,
backup = TRUE
)
Arguments
fn |
One or more filenames ending in "*.Rmd". |
wd |
A working directory in which the Rmd file exists. Leave as NULL if file is in current working directory, |
... |
Arguments that will be passed to |
verbose |
The opposite of render(quiet = TRUE). Shows compile commentary and pandoc command. Can be informative! |
purl |
Default TRUE |
tangle |
Default TRUE, synonym for purl |
backup |
Default TRUE. Will create backup copies of pdf, R, Rnw
files before replacing them. Uses |
Details
Running this will be the same as running the rmd2pdf.sh script within the directory.
Value
A vector of output file names
Author(s)
Paul Johnson <pauljohn@ku.edu>
Examples
tdir <- tempdir()
fmt <- "rmd2pdf-guide"
dirout <- initWriteup(fmt, dir = file.path(tdir, fmt))
print(dirout)
list.files(dirout)
of1 <- try(rmd2pdf("skeleton.Rmd", wd = dirout))
if(inherits(of1, "try-error")){
MESSG <- paste("Compiling the markdown file failed, perhaps",
"you should run with parameters verbose=TRUE",
"and keep_tex=TRUE")
print(MESSG)
} else {
## Check the result file:
MESSG <- paste("Check the directory", dirout, "for results.")
print(MESSG)
list.files(dirout)
if(interactive() && file.exists(file.path(dirout, "skeleton.pdf"))) {
browseURL(of1)
}
}
unlink(dirout)