exec_r {sys} | R Documentation |
Execute R from R
Description
Convenience wrappers for exec_wait and exec_internal that shell out to
R itself: R.home("bin/R")
.
Usage
r_wait(
args = "--vanilla",
std_out = stdout(),
std_err = stderr(),
std_in = NULL
)
r_internal(args = "--vanilla", std_in = NULL, error = TRUE)
r_background(args = "--vanilla", std_out = TRUE, std_err = TRUE, std_in = NULL)
Arguments
args |
command line arguments for R |
std_out |
if and where to direct child process |
std_err |
if and where to direct child process |
std_in |
a file to send to stdin, usually an R script (see examples). |
error |
automatically raise an error if the exit status is non-zero. |
Details
This is a simple but robust way to invoke R commands in a separate process. Use the callr package if you need more sophisticated control over (multiple) R process jobs.
See Also
Other sys:
exec
Examples
# Hello world
r_wait("--version")
# Run some code
r_wait(c('--vanilla', '-q', '-e', 'sessionInfo()'))
# Run a script via stdin
tmp <- tempfile()
writeLines(c("x <- rnorm(100)", "mean(x)"), con = tmp)
r_wait(std_in = tmp)