Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread hihi
Thank you all, it will help :-) Bye, Peter __ 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, repr

Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread Peter Langfelder
On Tue, Mar 15, 2011 at 1:17 PM, hihi wrote: > Hi All, > is there any effiective and dense/compact method to calculate the mean of a > list of - of course coincident - matrices on an element by element basis? The > resulting matrix' [i, j]-th element is the mean of the list's matrices' [i, > j]

Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread Henrique Dallazuanna
Try this: l <- list(matrix(rnorm(9), 3), matrix(rnorm(9), 3), matrix(rnorm(9), 3)) Reduce('+', l) / length(l) On Tue, Mar 15, 2011 at 5:17 PM, hihi wrote: > Hi All, > is there any effiective and dense/compact method to calculate the mean of a > list of - of course coincident - matrices on an e

Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread Claudia Beleites
Peter, as the matrices in the list have the same shape, you can unlist them into an array and then use rowMeans. HTH Claudia Am 15.03.2011 21:17, schrieb hihi: Hi All, is there any effiective and dense/compact method to calculate the mean of a list of - of course coincident - matrices on a

[R] Element by element mean of a list of matrices

2011-03-15 Thread hihi
Hi All, is there any effiective and dense/compact method to calculate the mean of a list of - of course coincident - matrices on an element by element basis? The resulting matrix' [i, j]-th element is the mean of the list's matrices' [i, j]-th elements respectively... Iterating by for statement