Possible Duplicate:
Sum a list of matrices
Add together a list of matrices element-by-element
I have a R list object. Each element of the list contains 3 by 3 matrix. I want to sum all the matrices element-wise. That is:
myList <- list();
myList[[1]] <- matrix(1:9,3,3)
myList[[2]] <- matrix((1:9)*10,3,3)
Then I want the final output output
myList[[1]]+myList[[2]]
[,1] [,2] [,3]
[1,] 11 44 77
[2,] 22 55 88
[3,] 33 66 99
Of course I can write a loop for this calculation but loop in R is very slow. Is there built in function in R which does this business?