Dear list,

I have a list of three matrices :

i = list(matrix(1:4,2,2), matrix(3:6,2,2), matrix(9:12,2,2))

I would like to sum the matrices, as follows :

[,1] [,2]
[1,] 13 19
[2,] 16 22

I used this code :

k <- i[[1]]
for (j in (2:length(i))) {
k <- k + i[[j]]}

But, is it possible to sum without a loop ?

Thanks in advance,
Carlos

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to