rscript: Run an R script

Description Usage Arguments

View source: R/rscript.R

Description

It uses the Rscript program corresponding to the current R vesion, to run the script. It streams stdout and stderr of the process.

Usage

1
2
3
4
5
6
7
rscript(script, cmdargs = character(), libpath = .libPaths(),
  repos = c(getOption("repos"), c(CRAN = "https://cloud.r-project.org")),
  stdout = NULL, stderr = NULL, poll_connection = TRUE,
  echo = FALSE, show = TRUE, callback = NULL,
  block_callback = NULL, spinner = FALSE, system_profile = FALSE,
  user_profile = FALSE, env = rcmd_safe_env(), timeout = Inf,
  wd = ".", fail_on_status = TRUE, color = TRUE)

Arguments

script

Path of the script to run.

cmdargs

Command line arguments.

libpath

The library path.

repos

The repos option. If NULL, then no repos option is set. This options is only used if user_profile or system_profile is set FALSE, as it is set using the system or the user profile.

stdout

Optionally a file name to send the standard output to.

stderr

Optionally a file name to send the standard error to.

poll_connection

Whether to have a control connection to the process. This is used to transmit messages from the subprocess to the parent.

echo

Whether to echo the complete command run by rcmd.

show

Logical, whether to show the standard output on the screen while the child process is running. Note that this is independent of the stdout and stderr arguments. The standard error is not shown currently.

callback

A function to call for each line of the standard output and standard error from the child process. It works together with the show option; i.e. if show = TRUE, and a callback is provided, then the output is shown of the screen, and the callback is also called.

block_callback

A function to call for each block of the standard output and standard error. This callback is not line oriented, i.e. multiple lines or half a line can be passed to the callback.

spinner

Whether to show a calming spinner on the screen while the child R session is running. By default it is shown if show = TRUE and the R session is interactive.

system_profile

Whether to use the system profile file.

user_profile

Whether to use the user's profile file.

env

Environment variables to set for the child process.

timeout

Timeout for the function call to finish. It can be a base::difftime object, or a real number, meaning seconds. If the process does not finish before the timeout period expires, then a system_command_timeout_error error is thrown. Inf means no timeout.

wd

Working directory to use for running the command. Defaults to the current working directory.

fail_on_status

Whether to throw an R error if the command returns with a non-zero status code. By default no error is thrown.

color

Whether to use terminal colors in the child process, assuming they are active in the parent process.


r-pkgs/callr documentation built on Nov. 9, 2018, 4:28 p.m.