R: Extract function from a call

call_fn {rlang} | R Documentation

## 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 deprecated and renamed to `call_fn()`. See lifecycle section in `call2()` for more about this change.

### See Also

`call_name()`

### Examples

    # Extract from a quoted call:
    call_fn(quote(matrix()))
    call_fn(quo(matrix()))

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

[Package rlang version 0.4.2 Index]