Rscript_call {xfun}R Documentation

Call a function in a new R session via Rscript()

Description

Save the argument values of a function in a temporary RDS file, open a new R session via Rscript(), read the argument values, call the function, and read the returned value back to the current R session.

Usage

Rscript_call(fun, args = list())

Arguments

fun

A function, or a character string that can be parsed and evaluated to a function.

args

A list of argument values.

Value

The returned value of the function in the new R session.

Examples

factorial(10)
# should return the same value
xfun::Rscript_call("factorial", list(10))

# the first argument can be either a character string or a function
xfun::Rscript_call(factorial, list(10))

[Package xfun version 0.18 Index]