This help topic is for R version 0.64.2. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/match.fun.html
match.fun {base}R Documentation

Function Verification for “Function Variables”

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.

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.

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
## Not run: 
match.fun(outer, descend = FALSE) #-> Error:  not a function

## End(Not run)
match.fun(outer) # finds it anyway
is.function(match.fun("outer")) # as well

[Package base version 0.64.2 ]