Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-30 Thread Dimitri Liakhovitski
Below is the script that was based on your help - it works very fast: ### Creating the example data set: set.seed(123) MyData-data.frame(group=c(rep(first,10),rep(second,10)),a=abs(round(rnorm(20,mean=0, sd=.55),2)), b=abs(round(rnorm(20,mean=0, sd=.55),2))) MyData ### Specifying parameters used

Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-29 Thread Dimitri Liakhovitski
Would like to thank every one once more for your great help. I was able to reduce the time from god knows how many hours to about 2 minutes! Really appreciate it! Dimitri On Sat, Mar 27, 2010 at 11:43 AM, Martin Morgan mtmor...@fhcrc.org wrote: On 03/26/2010 06:40 PM, Dimitri Liakhovitski wrote:

Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-27 Thread Martin Morgan
On 03/26/2010 06:40 PM, Dimitri Liakhovitski wrote: My sincere apologies if it looked large. Let me try again with less code. It's hard to do less than that. In fact - there is nothing in this code but 1 formula and many loops, which is the problem I am not sure how to solve. I also tried to

Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-27 Thread hadley wickham
 exp1^(a[case] * l * 10) would be better written out of the loop as  b - exp1^(a * l * 10) And even better as b - exp(a * l * 10) Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/

Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-27 Thread Sharpie
hadley wickham wrote:  exp1^(a[case] * l * 10) would be better written out of the loop as  b - exp1^(a * l * 10) And even better as b - exp(a * l * 10) Hadley Aye, exp() functions tend to be heavily optimized compared to general functions such as `^` even if e is used as the

Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-26 Thread Bert Gunter
Dmitri: If you follow the R posting guide you're more likely to get useful replies. In particular it asks for **small** reproducible examples -- your example is far more code then I care to spend time on anyway (others may be more willing or more able to do so of course). I suggest you try (if

Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-26 Thread Dimitri Liakhovitski
My sincere apologies if it looked large. Let me try again with less code. It's hard to do less than that. In fact - there is nothing in this code but 1 formula and many loops, which is the problem I am not sure how to solve. I also tried to be as clear as possible with the comments. Dimitri ##

Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-26 Thread Steven McKinney
Hi Dimitri Your code is complex, so this won't be easy for anyone to deparse. I think part of the issue is in the calculation you are doing in your innermost loop data[data[[group.var]] %in% subgroup, name][case]= 1-((1-data[data[[group.var]] %in% subgroup,