Run R functions, scripts and R CMD in separate R processes
open sourceMITfree
callr runs a computation in a separate R process without affecting the current one. It calls an R function with its arguments in a subprocess and copies the return value back, along with error objects and their stack traces, and it shows or collects the subprocess's standard output and error. Subprocesses can be one-off or persistent and run synchronously or in the background, and callr can also run R CMD commands and R scripts.
Problems it solves
- run an R function in a clean separate R session and get its result back
- run several R jobs in the background from my R session and poll them
- call R CMD check or an R script from inside R without blocking
Features
- calls an R function with arguments in a subprocess and copies the result back
- copies error objects back from the subprocess, with a stack trace
- shows or collects the subprocess's standard output and error
- one-off and persistent R subprocesses, synchronous or in the background
- runs R CMD commands and R scripts
- extensible r_process, rcmd_process and rscript_process R6 classes
- OpenTelemetry traces for every R subprocess
