Dear useRs,

I have a list, each entry of which is a matrix of constant dimensions. Is there a good way (i.e., not using a for loop) to apply a mean to each matrix entry *across list entries*?

Example:

foo <- list(rbind(c(1,2,3),c(4,5,6)),rbind(c(7,8,9),c(10,11,12)))
some.sort.of.apply(foo,FUN=mean)

I'm looking for a componentwise mean across the two entries of foo, i.e., the following output:

     [,1] [,2] [,3]
[1,]    4    5    6
[2,]    7    8    9

[NB. My "real" application involves trimming and psych::winsor(), so anything that generalizes to this would be extra good.]

I've been looking at apply and {s,l,m,t}apply, by, with and aggregate and searched the list archives... any ideas?

Thanks a lot,
Stephan

______________________________________________
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