Re: [R] Code is too slow: mean-centering variables in a data frame by subgroup

2010-03-30 Thread Dimitri Liakhovitski
I meant - even if 0 = 0.004 D. On Tue, Mar 30, 2010 at 12:47 PM, Dimitri Liakhovitski wrote: > Dear Charles, thank you so much! > On my example data frame you code takes 0 sec and mine - 0.05 sec - a > huge difference even if 0 = 0.04 sec. > Dimitri > > > On Tue, Mar 30, 2010 at 12:30 PM, Dimitri

Re: [R] Code is too slow: mean-centering variables in a data frame by subgroup

2010-03-30 Thread Dimitri Liakhovitski
Dear Charles, thank you so much! On my example data frame you code takes 0 sec and mine - 0.05 sec - a huge difference even if 0 = 0.04 sec. Dimitri On Tue, Mar 30, 2010 at 12:30 PM, Dimitri Liakhovitski wrote: > Thanks a lot, Charles - I'll try your approach. > Yes - don't worry about dividing

Re: [R] Code is too slow: mean-centering variables in a data frame by subgroup

2010-03-30 Thread Dimitri Liakhovitski
Thanks a lot, Charles - I'll try your approach. Yes - don't worry about dividing by negative means - in real data all values are positive. Dimitri On Tue, Mar 30, 2010 at 12:24 PM, Charles C. Berry wrote: > On Tue, 30 Mar 2010, Dimitri Liakhovitski wrote: > >> Dear R-ers, >> >> I have  a large da

Re: [R] Code is too slow: mean-centering variables in a data frame by subgroup

2010-03-30 Thread Dgnn
I posted a similar problem last week (but with an uninformative subject header) See if this http://n4.nabble.com/a-vectorized-solution-to-some-simple-dataframe-math-td1692810.html#a1710410 this helps. -- View this message in context: http://n4.nabble.com/Code-is-too-slow-mean-centering-variab

Re: [R] Code is too slow: mean-centering variables in a data frame by subgroup

2010-03-30 Thread Charles C. Berry
On Tue, 30 Mar 2010, Dimitri Liakhovitski wrote: Dear R-ers, I have a large data frame (several thousands of rows and about 2.5 thousand columns). One variable ("group") is a grouping variable with over 30 levels. And I have a lot of NAs. For each variable, I need to divide each value by varia

Re: [R] Code is too slow: mean-centering variables in a data frame by subgroup

2010-03-30 Thread Dimitri Liakhovitski
I wrote a different code - but it takes twice as long as my original code. :( However, I thought I should share it as well - because the second part of the code is fast - it's the first part that's slow. Maybe there is a way to fix the first part... Thank you! group.var<-"group" subgroups<-levels