Examples for 'rlang::as_function'


Convert to function

Aliases: as_function is_lambda

Keywords:

### ** Examples

f <- as_function(~ .x + 1)
f(10)
[1] 11
g <- as_function(~ -1 * .)
g(4)
[1] -4
h <- as_function(~ .x - .y)
h(6, 3)
[1] 3
# Functions created from a formula have a special class:
is_lambda(f)
[1] TRUE
is_lambda(as_function(function() "foo"))
[1] FALSE

[Package rlang version 1.1.4 Index]