rcat | R Documentation |
Evaluates an RSP string and outputs the generated string.
## Default S3 method:
rcat(..., file=NULL, path=NULL, envir=parent.frame(), args="*", output="", buffered=TRUE,
append=FALSE, verbose=FALSE)
## Default S3 method:
rsource(file, path=NULL, envir=parent.frame(), output="", buffered=FALSE, ...)
... |
A |
file , path |
Alternatively, a file, a URL or a |
envir |
The |
args |
A named |
output |
A |
buffered |
If |
append |
Only applied if |
verbose |
See |
Returns (invisibly) the outputted RspStringProduct
.
Using Rscript
and rcat()
, it is possible to process
an RSP string and output the result from the command line. For example,
Rscript -e "R.rsp::rcat('A random integer in [1,<%=K%>]: <%=sample(1:K, size=1)%>')" --args --K=50
parses and evaluates the RSP string and outputs the result to standard output. A CLI-friendly alternative to the above is:
Rscript -e R.rsp::rcat "A random integer in [1,<%=K%>]: <%=sample(1:K, size=1)%>" --args --K=50
The rsource(file, ...)
is a convenient wrapper
for rcat(file=file, ..., output="", buffered=FALSE)
.
As an analogue, rsource()
is to an RSP file what
source()
is to an R script file.
Henrik Bengtsson
To store the output in a string (instead of displaying it), see
rstring
().
For evaluating and postprocessing an RSP document and
writing the output to a file, see rfile
().
rcat("A random integer in [1,100]: <%=sample(1:100, size=1)%>\n")
# Passing arguments
rcat("A random integer in [1,<%=K%>]: <%=sample(1:K, size=1)%>\n", args=list(K=50))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.