Function Verification for ``Function Variables''

Usage

match.fun(FUN, descend=TRUE)

Arguments

FUN function, e.g. as passed to outer.
descend logical; control whether to search under non-function objects.

Description

Matches 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.

Details

If 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.

Value

A function matching FUN or an error is generated.

Bug/Feature

A character argument to FUN is always matched to a function, even if there is a non-function object higher up the search list with the same name.

Author(s)

Jonathan Rougier

See Also

match.arg

Examples

# 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


[Package Contents]