Learn R Programming

gsubfn (version 0.3-1)

match.funfn: Generic extended version of R match.fun

Description

A generic match.fun.

Usage

match.funfn(x, ...)
## S3 method for class 'formula':
match.funfn(x, ...)
## S3 method for class 'default':
match.funfn(x, ...)

Arguments

x
Function, character name of function or formula describing function.
...
Not used.

Value

  • Returns a function.

Details

The default method is the same as match.fun and the formula method is the same as as.function.formula. This function can be used within the body of a function to convert a function specification whether its a function, character string or formula into an actual function.

See Also

See Also match.fun, as.function.formula.

Examples

Run this code
# return first argument evaluated at second argument squared.
sq <- function(f, x) f(x^2)

# call sq using different forms for function
sq(function(x) exp(x)/x, pi)
f <- function(x) exp(x)/x
sq("f", pi)
sq(~ exp(x)/x, pi)
sq(x ~ exp(x)/x, pi)

Run the code above in your browser using DataLab