Learn R Programming

callr (version 3.7.6)

r_process: External R Process

Description

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.

Arguments

Super class

processx::process -> r_process

Methods

Inherited methods


Method new()

Start a new R process in the background.

Usage

r_process$new(options)

Arguments

options

A list of options created via r_process_options().

Returns

A new r_process object.


Method 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.

Usage

r_process$get_result()

Returns

The return value of the R expression evaluated in the R process.


Method finalize()

Clean up temporary files once an R process has finished and its handle is garbage collected.

Usage

r_process$finalize()


Method clone()

The objects of this class are cloneable with this method.

Usage

r_process$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
if (FALSE) {
## 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