fn_fmls {rlang} | R Documentation |
fn_fmls()
returns a named list of formal arguments.
fn_fmls_names()
returns the names of the arguments.
fn_fmls_syms()
returns formals as a named list of symbols. This
is especially useful for forwarding arguments in constructed
calls.
fn_fmls(fn = caller_fn()) fn_fmls_names(fn = caller_fn()) fn_fmls_syms(fn = caller_fn())
fn |
A function. It is lookep up in the calling frame if not supplied. |
Unlike formals()
, these helpers also work with primitive
functions. See is_function()
for a discussion of primitive and
closure functions.
lang_args()
and lang_args_names()
# Extract from current call: fn <- function(a = 1, b = 2) fn_fmls() fn() # Works with primitive functions: fn_fmls(base::switch) # fn_fmls_syms() makes it easy to forward arguments: lang("apply", !!! fn_fmls_syms(lapply))