Run an R process that mimics the current R process
No extra repositories are set up.
--no-restorecommand line arguments are not used. (But
The system profile and the user profile are loaded.
No extra environment variables are set up.
r_copycat(func, args = list(), libpath = .libPaths(), repos = getOption("repos"), cmdargs = "--slave", system_profile = TRUE, user_profile = TRUE, env = character(), ...)
Function object to call in the new R process. The function should be self-contained and only refer to other functions and use variables explicitly from other packages using the
::notation. The environment of the function is set to
.GlobalEnvbefore passing it to the child process. Because of this, it is good practice to create an anonymous function and pass that to
callr, instead of passing a function object from a (base or other) package. In particular
does not work, because
.libPathsis defined in a special environment, but
works just fine.
Arguments to pass to the function. Must be a list.
The library path.
NULL, then no
reposoption is set. This options is only used if
FALSE, as it is set using the system or the user profile.
Command line arguments to pass to the R process. Note that
c("-f", rscript)is appended to this,
rscriptis the name of the script file to run. This contains a call to the supplied function and some error handling code.
Whether to use the system profile file.
Whether to use the user's profile file.
Environment variables to set for the child process.
Additional arguments are passed to