It's trivial -- and many R functions do this. ?outer,?sapply for example. Once can also return a function. ?approxfun for example
Trivial example that shows how to use ... to pass in extra arguments to fun chooseFun<-function(dat=1:10,fun=mean,...)fun(dat,...) chooseFun() x<-rnorm(100) chooseFun(x,median) chooseFun(x,hist) chooseFun(x,hist,col='gray') -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Afshartous, David > Sent: Friday, October 07, 2005 11:03 AM > To: r-help@stat.math.ethz.ch > Subject: [R] function agruments > > All, > > When defining the arguments of a function, is it possible to > supply a function as > an argument? If so, how is this introduced into the function > code as well? > > For example, in the body of the function I have: > > result = function(x) > > and I'd like to supply either function.1 or function.2. > > Please reply directly to [EMAIL PROTECTED] > > Thanks! > Dave > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html