Skip to contents

Uses codetools::findGlobals() to enumerate all global symbol references in fn_body, then removes:

  • Language primitives and operators.

  • NSE false-positives: data-masked column names in tidyverse verbs, .data$ pronouns, {{ }} injections, and rlang::enquo()/sym() args.

Usage

find_calls_in_body(fn_body)

Arguments

fn_body

An R language object (the body expression of a function, i.e.\ body(f) or the third element of a parsed function(...) call).

Value

A character vector of symbol names that represent real function calls, sorted and de-duplicated. Returns character(0) on error.

Details

For pkg::fn and pkg:::fn patterns the symbol is verified to exist as a function in the package namespace before being included.

Examples

fn <- function(x) sqrt(x) + log(x)
find_calls_in_body(body(fn))
#> [1] "log"  "sqrt"
# [1] "log"  "sqrt"