Return a character vector containing the name of all the functions in an expression or a call.
expr_funs(expr, max.names = -1L, unique = FALSE, exclude.names = NULL)
an expression or call from which the name of the function are to be extracted.
the maximum number of names to be returned. -1 indicates no limit (other than vector size limits).
a logical value which indicates whether duplicate names should be removed from the value.
a character vector with names to exclude, or NULL
for none.
A character vector with the extracted function names.
The c code is adapted from base R code do_allnames()
(the later one allows
to extract either variables, or variables + functions, but not functions
alone).
# A formula where some names are simultaneously functions and variables
ff <- ~z(x, y, z, TRUE, "test", l = 4) + (y(z, x(l)) + y(2))
all.vars(ff)
#> [1] "x" "y" "z" "l"
all.names(ff, unique = TRUE)
#> [1] "~" "+" "z" "x" "y" "(" "l"
expr_funs(ff)
#> [1] "~" "+" "z" "(" "+" "y" "x" "y"
expr_funs(ff, unique = TRUE)
#> [1] "~" "+" "z" "(" "y" "x"
expr_funs(ff, exclude.names = "~")
#> [1] "+" "z" "(" "+" "y" "x" "y"