do.call.stash: Execute a Function Call and Stash the Result

Description Usage Arguments Examples

View source: R/stash.R

Description

Similar to 'do.call', 'do.call.stash' constructs and executes a function call. Additionally, 'do.call.stash' stores the result indexed by the function body, its arguments, and its dependencies.

Usage

1
2
## S3 method for class 'call.stash'
do(fun, argslist)

Arguments

fun

Function to apply. Unlike 'do.call', strings naming the function are not supported

argslist

List of arguments to 'fun', in order.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
heavy_function <- function(x) {
  Sys.sleep(3)
  mean(x)
}

result <- NULL
system.time({result <- do.call.stash(heavy_function, list(c(1:20)))})
result
system.time({result <- do.call.stash(heavy_function, list(c(1:20)))})
result

## End(Not run)

MrMallIronmaker/stash documentation built on Feb. 5, 2022, 8:12 a.m.