as_function {rando}R Documentation

Convert to function

Description

This function is a wrapper around rlang::as_function() which adds a two extra features:

Usage

as_function(x, env = parent.frame())

Arguments

x

a function or formula, see rlang::as_function() for more information

env

Environment in which to fetch the function in case x is a string

Value

Either:

Examples


f1 <- as_function(mean)
f1(1:10)

f2 <- as_function("sum")
f2(1,2,3)

f3 <- as_function(~.x + 1)
f3(9)

f4 <- as_function(~ .t + 1)
f4(10)

f5 <- as_function(~.x + .y)
f5(1,2)

f6 <- as_function(~ .t + alpha)
f6(10, alpha = 2)


[Package rando version 0.2.0 Index]