Learn R Programming

rlang (version 0.2.2)

call_fn: Extract function from a call

Description

If a frame or formula, the function will be retrieved from the associated environment. Otherwise, it is looked up in the calling frame.

Usage

call_fn(call, env = caller_env())

Arguments

call

Can be a call or a quosure that wraps a call.

env

The environment where to find the definition of the function quoted in call in case call is not wrapped in a quosure.

Life cycle

In rlang 0.2.0, lang_fn() was soft-deprecated and renamed to call_fn(). See lifecycle section in call2() for more about this change.

See Also

call_name()

Examples

Run this code
# NOT RUN {
# Extract from a quoted call:
call_fn(quote(matrix()))
call_fn(quo(matrix()))

# Extract the calling function
test <- function() call_fn(call_frame())
test()
# }

Run the code above in your browser using DataLab