[R] returning a list of functions
Rajat Mukherjee
rajat.mukherjee at rdls.nestle.com
Wed Jan 27 16:36:51 CET 2010
Hi interested readers,
I have a function that creates several functions within a loop and I would like
them to be returned for further use as follows:
Main.Function(df,...){
# df is a multivariate data
funcList<-list(NULL)
for (i in 1:ncol(df)){
temp<-logspline(df[,i],...) # logspline density estimate
funcList[[i]]<-function(x){expression(temp,x)}
}
return(funcList)
}
I have tried this, unfortunately can't figure out why all the functions
returned are identical.
Any help towards this will be much appreciated. Thanks.
More information about the R-help
mailing list