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

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Tue, 15 Mar 2011 17:38:47 -0300

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 <v.p.mail_at_freemail.hu> 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]-th elements respectively...
> Iterating by for statement is quite straightforward, but I am seeking for a
> more elegant solution, and my attempt with the apply family of functions did
> not work.
>
> Thank you,
> by
> Peter
>
> ______________________________________________
> R-help_at_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]]


______________________________________________ R-help_at_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.

Received on Tue 15 Mar 2011 - 20:42:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 15 Mar 2011 - 20:50:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive