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.function | returns a function created from x, if
it is not already a function. |
is.function | returns TRUE if x is a function;
otherwise, it returns an error. |
See Also
Examples
polynom <- function(x)
{
x^2 + 3 * x - 6
}
is.function(polynom) # returns TRUE
as.function(alist(x=, y=1, x+1))