Re: [R] simplify loop

2005-05-11 Thread Barry Rowlingson
Omar Lakkis wrote: Is there a way to implement this faster than doing it in a loop. for (i in length(settle)-1:1) { settle[i] = settle[i+1]/(1 + settle.pct[i+1]) } You dont need a loop at all here. How so? Well, as it is written the code in the for loop only exec

Re: [R] simplify loop

2005-05-11 Thread Prof Brian Ripley
It is, backwards, a cumulative product so you could use cumprod. On Wed, 11 May 2005, Omar Lakkis wrote: Is there a way to implement this faster than doing it in a loop. for (i in length(settle)-1:1) { settle[i] = settle[i+1]/(1 + settle.pct[i+1]) } I want to guarantee

Re: [R] simplify loop

2005-05-11 Thread Achim Zeileis
On Wed, 11 May 2005 13:05:58 -0400 Omar Lakkis wrote: > Is there a way to implement this faster than doing it in a loop. > > for (i in length(settle)-1:1) { > settle[i] = settle[i+1]/(1 + settle.pct[i+1]) > } > > I want to guarantee that i+1 is calculated before

[R] simplify loop

2005-05-11 Thread Omar Lakkis
Is there a way to implement this faster than doing it in a loop. for (i in length(settle)-1:1) { settle[i] = settle[i+1]/(1 + settle.pct[i+1]) } I want to guarantee that i+1 is calculated before i __ R-help@stat.math.et