Try this:

u <- 1:10
mean(sapply(Y, function(f)match.fun(f)(u)))

On Tue, Nov 16, 2010 at 9:00 PM, Eduardo de Oliveira Horta <
eduardo.oliveirahorta@gmail.com> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

