[R] sum of list elements

Richard M. Heiberger rmh at temple.edu
Fri Jul 3 05:22:05 CEST 2009


I think you are asking for Reduce

 > Reduce(`+`, a)
      [,1] [,2] [,3]
[1,]    3    0    0
[2,]    0    3    0
[3,]    0    0    3
 >

You might be asking for do.call with some function's name as its first 
argument.

 > do.call("sum", a)
[1] 9
 >




More information about the R-help mailing list