sum
On Wednesday 23 April 2003 12:57 pm, 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...
If the list is not too long, perhaps
sumlist <-
function(x)
if (length(x) > 2) sumlist(x[1:2]) +
sumlist(x[-(1:2)]) else do.call("+", x)
sumlist(<whatever your list is>)
-Deepayan