The R Project SVN R

Rev

Rev 61433 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/base/man/as.function.Rd
68948 ripley 2
% Part of the R package, https://www.R-project.org
59039 ripley 3
% Copyright 1995-2007 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
1180 pd 6
\name{as.function}
7
\title{Convert Object to Function}
8
\usage{
7324 ripley 9
as.function(x, \dots)
1180 pd 10
 
25360 ripley 11
\method{as.function}{default}(x, envir = parent.frame(), \dots)
1180 pd 12
}
56186 murdoch 13
\alias{as.function}
1180 pd 14
\alias{as.function.default}
15
\arguments{
15514 ripley 16
  \item{x}{object to convert, a list for the default method.}
7324 ripley 17
  \item{\dots}{additional arguments, depending on object}
1180 pd 18
 
7324 ripley 19
  \item{envir}{environment in which the function should be defined}
1180 pd 20
}
21
\description{
7324 ripley 22
  \code{as.function} is a generic function which is used to convert
23
  objects to functions.
1180 pd 24
 
7324 ripley 25
  \code{as.function.default} works on a list \code{x}, which should contain the
26
  concatenation of a formal argument list and an expression or an
27
  object of mode \code{"\link{call}"} which will become the function body.
28
  The function will be defined in a specified environment, by default
29
  that of the caller.
1180 pd 30
}
33595 murdoch 31
\note{
32
  For ancient historical reasons, \code{envir = NULL} uses the global
61433 ripley 33
  environment rather than the base environment.
33595 murdoch 34
  Please use \code{envir = \link{globalenv}()} instead if this is what you want,
35
  as the special handling of \code{NULL} may change in a future release.
36
}
1180 pd 37
\value{
7324 ripley 38
  The desired function.
1180 pd 39
}
1209 maechler 40
\author{Peter Dalgaard}
41
\seealso{
42
  \code{\link{function}};
7324 ripley 43
  \code{\link{alist}} which is handy for the construction of
1209 maechler 44
  argument lists, etc.
45
}
1180 pd 46
\examples{
61168 ripley 47
as.function(alist(a = , b = 2, a+b))
61150 ripley 48
as.function(alist(a = , b = 2, a+b))(3)
1180 pd 49
}
24049 ripley 50
\keyword{programming}