r_process: External R Process

r_processR Documentation

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.

Super class

processx::process -> r_process

Methods

Public methods

Inherited methods

r_process$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.


r_process$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.


r_process$cleanup()

Delete the temporary files created for this R process. Only call this if you are sure that the process is done and you don't need the result anymore. If you don't call this method explicitly, the temporary files will be deleted when the process object is garbage collected.

Usage
r_process$cleanup()

r_process$finalize()

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

Usage
r_process$finalize()

r_process$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


## 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()


callr documentation built on June 5, 2026, 5:06 p.m.