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)

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 Duncan Murdoch
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

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

2005-08-05 Thread Liaw, Andy
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Uwe Ligges > Sent: Friday, August 05, 2005 12:44 PM > To: Duncan Murdoch > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] Computing sums of the columns of an array > &

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

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 ste

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 comp

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 c

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 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 i

[R] Computing sums of the columns of an array

2005-08-05 Thread 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 __