Extract arguments from a call

lang_args(lang)

lang_args_names(lang)

Arguments

lang

Can be a call (language object), a formula quoting a call in the right-hand side, or a frame object from which to extract the call expression.

Value

A named list of arguments.

See also

lang_tail(), fn_fmls() and fn_fmls_names()

Examples

call <- quote(f(a, b)) # Subsetting a call returns the arguments converted to a language # object: call[-1]
#> a(b)
# See also lang_tail() which returns the arguments without # conversion as the original pairlist: str(lang_tail(call))
#> Dotted pair list of 2 #> $ : symbol a #> $ : symbol b
# On the other hand, lang_args() returns a regular list that is # often easier to work with: str(lang_args(call))
#> List of 2 #> $ : symbol a #> $ : symbol b
# When the arguments are unnamed, a vector of empty strings is # supplied (rather than NULL): lang_args_names(call)
#> [1] "" ""