rfile
Evaluates and postprocesses an RSP document and outputs the final RSP document file
Evaluates and postprocesses an RSP document and outputs the final RSP document file.
Usage
# S3 method for default
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
connection
. If a file, thepath
is prepended to the file, iff given.- output
A
character
string or aconnection
specifying where output should be directed. The default is a file with a filename where the file extension (typically".rsp"
) has been dropped fromfile
in the directory given by theworkdir
argument.- workdir
The working directory to use after parsing and preprocessing, but while evaluating and postprocessing the RSP document. If argument
output
specifies an absolute pathname, then the directory ofoutput
is used, otherwise the current directory is used.- type
The default content type of the RSP document. By default, it is inferred from the
output
filename extension, iff possible.- envir
The
environment
in which the RSP document is preprocessed and evaluated.- args
A named
list
of arguments assigned to the environment in which the RSP string is parsed and evaluated. SeecmdArgs
.- postprocess
If
TRUE
, and a postprocessing method exists for the generated RSP product, it is postprocessed as well.- ...
Additional arguments passed to the RSP engine.
- verbose
See
Verbose
.
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(file='RSP_refcard.tex.rsp', path=system.file('doc', package='R.rsp'))"
parses and evaluates RSP_refcard.tex.rsp
and output RSP_refcard.pdf
in the current directory.
See Also
Examples
# NOT RUN {
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)
}
# }