match.fun(FUN, descend=TRUE)
FUN
|
function, e.g. as passed to outer.
|
descend
| logical; control whether to search under non-function objects. |
FUN to a function, where FUN can be a
character (string), e.g., "*" or "fred",
or a function such as pmax.
Returns an error if no matching function is found.
descend=TRUE, match.fun will look underneath
non-function objects with the given name; otherwise if FUN
points to a non-function object then an error is generated.
This is now used in base functions such as
apply, lapply, outer,
sweep, and the like.
FUN or an error is generated.FUN is always matched to a
function, even if there is a non-function object higher up the
search list with the same name.match.arg
# Same as get("*"):
match.fun("*")
# Overwrite outer with a vector
outer <- 1:5
match.fun(outer, descend = FALSE) #-> Error: not a function
match.fun(outer) # finds it anyway
is.function(match.fun("outer")) # as well