Examples for 'rlang::fn_fmls'


Extract arguments from a function

Aliases: fn_fmls fn_fmls_names fn_fmls_syms fn_fmls<- fn_fmls_names<-

Keywords:

### ** Examples

# Extract from current call:
fn <- function(a = 1, b = 2) fn_fmls()
fn()
$a
[1] 1

$b
[1] 2
# fn_fmls_syms() makes it easy to forward arguments:
call2("apply", !!! fn_fmls_syms(lapply))
apply(X = X, FUN = FUN, ...)
# You can also change the formals:
fn_fmls(fn) <- list(A = 10, B = 20)
fn()
$A
[1] 10

$B
[1] 20
fn_fmls_names(fn) <- c("foo", "bar")
fn()
$foo
[1] 10

$bar
[1] 20

[Package rlang version 1.1.4 Index]