lazy_eval {wrappr}R Documentation

save and Delay a function call with the option to change the function and arguments when called

Description

save and Delay a function call with the option to change the function and arguments when called

Usage

lazy_eval(..., .f)

Arguments

...

Additional arguments to be passed to the param .f. Also in closure function returned.

.f

function. A function that will be called when needed. Also in closure function returned.

Value

closure function with same param names plus the param names overwrite_args Boolean and return_new_closure Boolean.

Examples


numbers <- c(1,2,3,4,5)

func <- lazy_eval(numbers, .f = sum)

sum_result <- func()

max_result <- func(.f = max)

mean_result <- func(.f = mean)

range_result <- func(.f = function(...) { max(...) - min(...)})

add_more_num_result <- func(4,5,6, NA, na.rm = TRUE)

updated_func <- func(na.rm = TRUE, return_new_closure = TRUE)

updated_func_result <- updated_func()


[Package wrappr version 0.1.0 Index]