as_function: Convert to function

Description Usage Arguments Value Examples

View source: R/as_function.R

Description

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

Usage

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)

rando documentation built on Feb. 16, 2021, 5:07 p.m.