[R] sum

Vadim Ogranovich vograno at arbitrade.com
Wed Apr 23 20:25:13 CEST 2003


Luis,

I use this:

# sum of list l
l.sum <- l[[1]]  # just to create the result matrix with proper dimensions
and dimnames
l.sum[] <- colSums(do.call("rbind", l))

There might (or might not) be a problem if your matrix is stored by row.
Just a word caution as I never checked this out.

Hope this helps,
Vadim

> -----Original Message-----
> From: Luis Silva [mailto:lm.silva at sapo.pt]
> Sent: Wednesday, April 23, 2003 10:58 AM
> To: R help
> Subject: [R] sum
> 
> 
> 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...
> --
> 
> 
> http://adsl.sapo.pt
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-------------------------------------------------- 
DISCLAIMER\ This e-mail, and any attachments thereto, is intende... {{dropped}}



More information about the R-help mailing list