[R] Summing up matrices in a list

From: Vicky Landsman <msvika_at_mscc.huji.ac.il>
Date: Thu 17 Mar 2005 - 03:21:47 EST


Dear all,
I think that my question is very simple but I failed to solve it. I have a list which elements are matrices like this:  

>mylist
[[1]]

     [,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6

[[2]]

     [,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12

I'd like to create a matrix M<-mylist[[1]]+mylist[[2]]

     [,1] [,2] [,3]
[1,] 8 12 16
[2,] 10 14 18

Is there a way to create M without looping? Thanks a lot,
Vicky Landsman.

        [[alternative HTML version deleted]]



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 03:23:48 2005

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