colSums() is a lot faster. 

Reid Huntsinger

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Martin C. Martin
Sent: Friday, August 05, 2005 12:17 PM
To: [email protected]
Subject: [R] Computing sums of the columns of an array


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

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to