An R process that runs in the background. This is an R6 class that extends the processx::process class. The process starts in the background, evaluates an R function call, and then quits.
processx::process
-> r_process
new()
Start a new R process in the background.
r_process$new(options)
options
A list of options created via r_process_options()
.
A new r_process
object.
get_result()
Return the result, an R object, from a finished
background R process. If the process has not finished yet, it throws
an error. (You can use wait()
method (see processx::process) to
wait for the process to finish, optionally with a timeout.) You can
also use processx::poll()
to wait for the end of the process,
together with other processes or events.
r_process$get_result()
The return value of the R expression evaluated in the R process.
finalize()
Clean up temporary files once an R process has finished and its handle is garbage collected.
r_process$finalize()
clone()
The objects of this class are cloneable with this method.
r_process$clone(deep = FALSE)
deep
Whether to make a deep clone.
# NOT RUN {
## List all options and their default values:
r_process_options()
## Start an R process in the background, wait for it, get result
opts <- r_process_options(func = function() 1 + 1)
rp <- r_process$new(opts)
rp$wait()
rp$get_result()
# }
Run the code above in your browser using DataLab