- Original Message -
From: Ales Ziberna [EMAIL PROTECTED]
To: R-help r-help@stat.math.ethz.ch
Sent: Wednesday, December 14, 2005 6:05 PM
Subject: The fastest way to select and execute a few selected functions
inside a function
Dear useRs?
I have the following problem! I have a
Dear useRs?
I have the following problem! I have a function that calls one or more
functions, depending on the input parameters. I am searching for the fastest
way to select and execute the selected functions and return their results in
a list. The number of possible functions is 10, however
Is this what you want?
myf-function(FUN, x){
res- vector( mode=list)
for(i in FUN)
res[[i]]-do.call(i,args=list(x))
return(res)
}
myf(FUN=mean,x=1:10)
myf(FUN=c(mean,max),x=1:10)
myf(FUN=c(mean,max, sum, median),x=1:10)
Ales