as.function
Function Objects

Description

Coerces to, or tests for, function objects (that is, objects with mode function).

Usage

as.function(x, ...)
as.function.default(x, envir = parent.frame(), ...)
is.function(x)

Arguments

x
  • for is.function, x can be any object.
  • for as.function, x must be either a function or a list. The first elements of the list must contain the formal arguments, and the last element must contain the body of the function.
envir the default method for as.function accepts an optional environment. It is ignored if x is already a function.

Details

as.function is generic; currently it has no methods.
Value
as.functionreturns a function created from x, if it is not already a function.
is.functionreturns TRUE if x is a function; otherwise, it returns an error.
See Also
alist, Syntax.
Examples
polynom <- function(x)
{
        x^2 + 3 * x - 6
}
is.function(polynom) # returns TRUE
as.function(alist(x=, y=1, x+1))
Package base version 6.0.0-69
Package Index