[R] Summing up matrices in a list

Thomas Lumley tlumley at u.washington.edu
Wed Mar 16 18:02:04 CET 2005


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




More information about the R-help mailing list