When called inside functions that take a function as argument, extract the desired function object while avoiding undesired matching to objects of other types.
match.fun(FUN, descend = TRUE)
| Parameter | Description |
|---|---|
FUN |
item to match as function: a function, symbol or character string. See ‘Details’. |
descend |
logical; control whether to search past non-function objects. |
# NOT RUN {
# Same as get("*"):
match.fun("*")
# Overwrite outer with a vector
outer <- 1:5
try(match.fun(outer, descend = FALSE)) #-> Error: not a function
match.fun(outer) # finds it anyway
is.function(match.fun("outer")) # as well
# }