Re: [R] Recursive algorithm

2010-11-01 Thread Barry Rowlingson
On Mon, Nov 1, 2010 at 10:12 AM, Megh Dal wrote: > Dear friend, I have to construct some recursive algorithm for which I used > some for loop like: > > res <- vector(length=1) > res[1] = 0 > for (i in 2:(1+1)) res[i] <- res[i-1]*some function > > I have noticed that this is taking

Re: [R] Recursive algorithm

2010-11-01 Thread David Winsemius
On Nov 1, 2010, at 6:12 AM, Megh Dal wrote: Dear friend, I have to construct some recursive algorithm for which I used some for loop like: res <- vector(length=1) res[1] = 0 for (i in 2:(1+1)) res[i] <- res[i-1]*some function res[2:(1+1)] <- res[1:1]*mysteryfunction

[R] Recursive algorithm

2010-11-01 Thread Megh Dal
Dear friend, I have to construct some recursive algorithm for which I used some for loop like: res <- vector(length=1) res[1] = 0 for (i in 2:(1+1)) res[i] <- res[i-1]*some function I have noticed that this is taking too much time. Is there any way to speed up things? Thanks,