Eduardo -
   I'd guess that

Ybar = function(u)mean(sapply(Y,function(fun)fun(u)))

will do what you want, but without a reproducible example,
it's hard to tell.
                                        - Phil Spector
                                         Statistical Computing Facility
                                         Department of Statistics
                                         UC Berkeley
                                         spec...@stat.berkeley.edu


On Tue, 16 Nov 2010, Eduardo de Oliveira Horta wrote:

Hello there

I have a list, Y, and each component of that list is a real-valued function
(that is, Y[[i]](u) returns a number).

I was wishing to build the mean function and the first thing I thought of
was

Ybar<-function(u){
  mean(Y[[1:n]](u))
}

but obviously this doesn't work, since Y[[1:n]] is not allowed at all.

Any elegant suggestions? I really would like to avoid something like

Ybar<-function(u){
  for (i in 1:n){
     Ybar<-Ybar + Ybar[[i]](u)
  }
  Ybar<-1/n*Ybar
}

Thanks in advance!

Best regards,

Eduardo Horta

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to