make_flow_fn: Explicit cache of a function

Description Usage Arguments Details Value Examples

View source: R/flow-functions.R

Description

Explicit cache of a function

Usage

1

Arguments

fn

Function to be cached, ideally a pure function.

fn_id

Optional id to uniquely identify the function. By default, rflow functions reuse the cache if the same function is given. The id allows the user to suppress console messages and to explicitly indicate whether to reuse the old cache or create a new one.

flow_options

List of options created using get_flow_options.

Details

In order to use the functionality of an R6Flow object, the output of make_flow_fn has to be collected first.

Value

The cached version of the function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fn <- function(x, y) { x + y + 1 }
make_flow_function <- make_flow_fn(fn)
rflow_function <- make_flow_function(2, 3)
flow_result <- rflow_function %>% collect()

# usage with rflow pipes
fn2 <- function(x, y) { x * y }
make_flow_function2 <- make_flow_fn(fn2)
collected_pipe_flow <- make_flow_function(1, 2) %>%
    make_flow_function2(2) %>%
    collect()

numeract/rflow documentation built on May 28, 2019, 3:39 p.m.