| rfile {R.rsp} | R Documentation |
Evaluates and postprocesses an RSP document and outputs the final RSP document file
Description
Evaluates and postprocesses an RSP document and outputs the final RSP document file.
Usage
## Default S3 method:
rfile(file, path=NULL, output=NULL, workdir=NULL, type=NA, envir=parent.frame(),
args="*", postprocess=TRUE, ..., verbose=FALSE)
Arguments
file, path |
Specifies the RSP file to processed, which can
be a file, a URL or a |
output |
A |
workdir |
The working directory to use after parsing and
preprocessing, but while evaluating and postprocessing
the RSP document.
If argument |
type |
The default content type of the RSP document. By default, it
is inferred from the |
envir |
The |
args |
A named |
postprocess |
If |
... |
Additional arguments passed to the RSP engine. |
verbose |
See |
Value
Returns an RspProduct.
If argument output specifies a file, then this is
an RspFileProduct.
Processing RSP files from the command line
Using Rscript and rfile(), it is possible to process
an RSP file from the command line. For example,
Rscript -e "R.rsp::rfile('RSP_refcard.tex.rsp')"
parses and evaluates ‘RSP_refcard.tex.rsp’ and output ‘RSP_refcard.pdf’ in the current directory. A CLI-friendly alternative to the above is:
Rscript -e R.rsp::rfile RSP_refcard.tex.rsp
Author(s)
Henrik Bengtsson
See Also
Examples
path <- system.file("exData", package="R.rsp")
pathname <- rfile("random.txt.rsp", path=path,
output=file.path(tempdir(), "random.txt"))
print(pathname)
lines <- readLines(pathname, warn=FALSE)
cat(lines, collapse="\n")
file.remove(pathname)
# Passing arguments
path <- system.file("exData", package="R.rsp")
pathname <- rfile("random-args.txt.rsp", path=path, args=list(K=50),
output=file.path(tempdir(), "random-args.txt"))
print(pathname)
lines <- readLines(pathname, warn=FALSE)
cat(lines, collapse="\n")
file.remove(pathname)
## Not run:
# Compile and display the main vignette (requires LaTeX)
if (isCapableOf(R.rsp, "latex")) {
path <- system.file("doc", package="R.rsp")
pdf <- rfile("Dynamic_document_creation_using_RSP.tex.rsp", path=path)
cat("Created document: ", pdf, "\n", sep="")
if (interactive()) browseURL(pdf)
}
## End(Not run)