Re: [R] get means of elements of 5 matrices in a list

2010-04-27 Thread David Freedman
thanks very much for the help - all of these suggestions were much better than what I was doing -- View this message in context: http://r.789695.n4.nabble.com/get-means-of-elements-of-5-matrices-in-a-list-tp2067722p2068329.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] get means of elements of 5 matrices in a list

2010-04-27 Thread Peter Ehlers
On 2010-04-27 9:05, David Freedman wrote: I've got a list of 5 matrices that are each 5 x 6. I'd like to end up with a 5 x 6 matrix that contains the mean value of the 5 original matrices. I can do this by brute force, but there must be a better way than making each matrix into a vector and th

Re: [R] get means of elements of 5 matrices in a list

2010-04-27 Thread David Winsemius
On Apr 27, 2010, at 11:05 AM, David Freedman wrote: I've got a list of 5 matrices that are each 5 x 6. I'd like to end up with a 5 x 6 matrix that contains the mean value of the 5 original matrices. I can do this by brute force, but there must be a better way than making each matrix i

Re: [R] get means of elements of 5 matrices in a list

2010-04-27 Thread Marc Schwartz
On Apr 27, 2010, at 10:19 AM, Marc Schwartz wrote: > On Apr 27, 2010, at 10:05 AM, David Freedman wrote: > >> >> I've got a list of 5 matrices that are each 5 x 6. I'd like to end up with a >> 5 x 6 matrix that contains the mean value of the 5 original matrices. I can >> do this by brute force

Re: [R] get means of elements of 5 matrices in a list

2010-04-27 Thread Marc Schwartz
On Apr 27, 2010, at 10:05 AM, David Freedman wrote: > > I've got a list of 5 matrices that are each 5 x 6. I'd like to end up with a > 5 x 6 matrix that contains the mean value of the 5 original matrices. I can > do this by brute force, but there must be a better way than making each > matrix i

Re: [R] get means of elements of 5 matrices in a list

2010-04-27 Thread Jorge Ivan Velez
Hi David, Here is a suggestion: matrix(colMeans(do.call(rbind, lapply(ll, function(x) as.vector(x, nrow = length(ll)) HTH, Jorge On Tue, Apr 27, 2010 at 11:05 AM, David Freedman <3.14da...@gmail.com>wrote: > > I've got a list of 5 matrices that are each 5 x 6. I'd like to end up with > a

[R] get means of elements of 5 matrices in a list

2010-04-27 Thread David Freedman
I've got a list of 5 matrices that are each 5 x 6. I'd like to end up with a 5 x 6 matrix that contains the mean value of the 5 original matrices. I can do this by brute force, but there must be a better way than making each matrix into a vector and then remaking a matrix thanks very much for a