as.function: Convert Object to Function

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/as.R

Description

as.function is a generic function which is used to convert objects to functions.

as.function.default works on a list x, which should contain the concatenation of a formal argument list and an expression or an object of mode "call" which will become the function body. The function will be defined in a specified environment, by default that of the caller.

Usage

1
2
3
4
as.function(x, ...)

## Default S3 method:
as.function(x, envir = parent.frame(), ...)

Arguments

x

object to convert, a list for the default method.

...

additional arguments, depending on object

envir

environment in which the function should be defined

Value

The desired function.

Note

For ancient historical reasons, envir = NULL uses the global environment rather than the base environment. Please use envir = globalenv() instead if this is what you want, as the special handling of NULL may change in a future release.

Author(s)

Peter Dalgaard

See Also

function; alist which is handy for the construction of argument lists, etc.

Examples

1
2
as.function(alist(a = , b = 2, a+b))
as.function(alist(a = , b = 2, a+b))(3)

robertzk/monadicbase documentation built on May 27, 2019, 10:35 a.m.