rcat

0th

Percentile

Evaluates an RSP string and outputs the generated string

Evaluates an RSP string and outputs the generated string.

Keywords
file, print, IO
Usage
# S3 method for default
rcat(..., file=NULL, path=NULL, envir=parent.frame(), args="*", output="", buffered=TRUE,
  append=FALSE, verbose=FALSE)
 # S3 method for default
rsource(file, path=NULL, envir=parent.frame(), output="", buffered=FALSE, ...)
Arguments
...

A character string with RSP markup.

file, path

Alternatively, a file, a URL or a connection from with the strings are read. If a file, the path is prepended to the file, iff given.

envir

The environment in which the RSP string is preprocessed and evaluated.

args

A named list of arguments assigned to the environment in which the RSP string is parsed and evaluated. See cmdArgs.

output

A connection, or a pathname where to direct the output. If "", the output is sent to the standard output.

buffered

If TRUE, and output="", then the RSP output is outputted as soon as possible, if possible.

append

Only applied if output specifies a pathname. If TRUE, then the output is appended to the file, otherwise the files content is overwritten.

verbose

See Verbose.

Value

Returns (invisibly) the outputted RspStringProduct.

Processing RSP strings from the command line

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.

rsource()

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.

See Also

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().

Aliases
  • rcat.default
  • rcat
  • rcat.RspString
  • rcat.RspDocument
  • rcat.RspRSourceCode
  • rcat.function
  • rcat.expression
  • rsource
  • rsource.default
  • rsource.RspString
  • rsource.RspDocument
  • rsource.RspRSourceCode
  • rsource.function
  • rsource.expression
Examples
# NOT RUN {
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))


# }
Documentation reproduced from package R.rsp, version 0.43.1, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.