Skip to content
Back to formatted view

Raw Message

Message-ID: <39B6DDB9048D0F4DAD42CB26AAFF0AFA64EB64@usctmx1106.Merck.com>
Date: 2005-08-05T16:22:29Z
From: Liaw, Andy
Subject: Computing sums of the columns of an array

See ?colSums.

Andy

> From: Martin C. Martin
> 
> Hi,
> 
> I have a 5x731 array A, and I want to compute the sums of the 
> columns.  
> Currently I do:
> 
> apply(A, 2, sum)
> 
> But it turns out, this is slow: 70% of my CPU time is spent 
> here, even 
> though there are many complicated steps in my computation.
> 
> Is there a faster way?
> 
> Thanks,
> Martin
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 
>