exec_r: Execute R from R

Description Usage Arguments Details See Also Examples

Description

Convenience wrappers for exec_wait and exec_internal that shell out to R itself: R.home("bin/R").

Usage

1
2
3
4
5
6
7
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 STDOUT. Must be one of TRUE, FALSE, filename, connection object or callback function. See section on Output Streams below for details.

std_err

if and where to direct child process STDERR. Must be one of TRUE, FALSE, filename, connection object or callback function. See section on Output Streams below for details.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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)

jeroen/sys documentation built on Dec. 17, 2018, 10:09 a.m.