Re: [R] Summing up matrices in a list

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Thu 17 Mar 2005 - 04:02:04 EST

On Wed, 16 Mar 2005, Adaikalavan Ramasamy wrote:

> mylist <- list( matrix(1:6, nc=3), matrix(7:12, nc=3) )
> do.call("+", mylist)
> [,1] [,2] [,3]
> [1,] 8 12 16
> [2,] 10 14 18
>

Yes, but this works only when the list is of length 2, when M<-mylist[[1]]+mylist[[2]] seems preferable.

         -thomas



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Mar 17 04:16:21 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:50 EST