sum
Luis Silva wrote:
Dear helpers I have a list where each element is a matrix (the list is obtained with lapply). I want to sum those matrices. Is there a function to do that? The sum function sums all the elements... --
How about:
R> r = list(matrix(1:4,2,2),matrix(5:8,2,2),matrix(9:12,2,2))
R> expr = paste("r[[",seq(along = r),"]]", collapse="+")
R> eval(parse(text = expr))
[,1] [,2]
[1,] 15 21
[2,] 18 24
Regards,
Sundar