The R Project SVN R

Rev

Rev 82689 | 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.}
85065 smeyer 17
  \item{\dots}{additional arguments to be passed to or from methods.}
18
  \item{envir}{environment in which the function should be defined.}
1180 pd 19
}
20
\description{
7324 ripley 21
  \code{as.function} is a generic function which is used to convert
22
  objects to functions.
1180 pd 23
 
7324 ripley 24
  \code{as.function.default} works on a list \code{x}, which should contain the
25
  concatenation of a formal argument list and an expression or an
26
  object of mode \code{"\link{call}"} which will become the function body.
27
  The function will be defined in a specified environment, by default
28
  that of the caller.
1180 pd 29
}
30
\value{
7324 ripley 31
  The desired function.
1180 pd 32
}
1209 maechler 33
\author{Peter Dalgaard}
34
\seealso{
35
  \code{\link{function}};
7324 ripley 36
  \code{\link{alist}} which is handy for the construction of
1209 maechler 37
  argument lists, etc.
38
}
1180 pd 39
\examples{
61168 ripley 40
as.function(alist(a = , b = 2, a+b))
61150 ripley 41
as.function(alist(a = , b = 2, a+b))(3)
1180 pd 42
}
24049 ripley 43
\keyword{programming}