Possible duplicate:
Make a list of matrices
Match list of items by item
I have a list object R. Each list item contains a 3 by 3 matrix. I want to sum all matrices by items. I.e:
myList <- list(); myList[[1]] <- matrix(1:9,3,3) myList[[2]] <- matrix((1:9)*10,3,3)
Then i need 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 the loop in R is very slow. Is there a built-in function in R that makes this business?
r
Theprincess
source share