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

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.

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


MangoTheCat/callr documentation built on Aug. 29, 2024, 2:32 a.m.