Re: [R] Computing sums of the columns of an array

2005-08-05 Thread Liaw, Andy
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

Re: [R] Computing sums of the columns of an array

2005-08-05 Thread Huntsinger, Reid
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: r-help@stat.math.ethz.ch Subject: [R] Computing sums of the columns of an array Hi, I have a 5x731

Re: [R] Computing sums of the columns of an array

2005-08-05 Thread Uwe Ligges
Martin C. Martin wrote: Hi, I have a 5x731 array A, and I want to compute the sums of the columns. Currently I do: apply(A, 2, sum) colSums(A) Uwe Ligges But it turns out, this is slow: 70% of my CPU time is spent here, even though there are many complicated steps in my

Re: [R] Computing sums of the columns of an array

2005-08-05 Thread Duncan Murdoch
On 8/5/2005 12:16 PM, Martin C. Martin wrote: 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.

Re: [R] Computing sums of the columns of an array

2005-08-05 Thread Gavin Simpson
On Fri, 2005-08-05 at 12:16 -0400, Martin C. Martin wrote: 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

Re: [R] Computing sums of the columns of an array

2005-08-05 Thread Uwe Ligges
Duncan Murdoch wrote: On 8/5/2005 12:16 PM, Martin C. Martin wrote: 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

Re: [R] Computing sums of the columns of an array

2005-08-05 Thread Martin C. Martin
Thanks everyone. Gavin Simpson wrote: But neither is that slow on my system. What is A? It's in the middle of a loop. I'm doing some maximum likelihood estimation, and having to evaluate my model over and over again for different parameter values. Thanks, Martin

Re: [R] Computing sums of the columns of an array

2005-08-05 Thread Uwe Ligges
Duncan Murdoch wrote: On 8/5/2005 12:43 PM, Uwe Ligges wrote: Duncan Murdoch wrote: On 8/5/2005 12:16 PM, Martin C. Martin wrote: 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