Re: [R] eval and assign in loop problem

2010-07-12 Thread David Winsemius
On Jul 12, 2010, at 7:16 AM, S.Nicholas wrote: Thank you Erik and Patrick, using vectorization and apply function seem to be very promising, even though I don't know how to use apply/sapply for updating discrete time difference equation instead of using for loop. (e.g, Nt+1 = Nt (1+R(K-Nt/K)))

Re: [R] eval and assign in loop problem

2010-07-12 Thread S.Nicholas
Thank you Erik and Patrick, using vectorization and apply function seem to be very promising, even though I don't know how to use apply/sapply for updating discrete time difference equation instead of using for loop. (e.g, Nt+1 = Nt (1+R(K-Nt/K))) Maybe I could use vector for different parameters

Re: [R] eval and assign in loop problem

2010-07-11 Thread Patrick Connolly
On Fri, 09-Jul-2010 at 08:25AM -0700, S.Nicholas wrote: |> deaR useRs, |> |> I am trying to assign different values to different objects in a for loop. |> The following is a toy example of the part that has been giving me a hard |> time. |> |> The first "for loop" generates four objects, b0, b1,

Re: [R] eval and assign in loop problem

2010-07-09 Thread Erik Iverson
for (i in 0:3) { r = runif(1) assign(paste('b',i,sep=''),r) } for (i in 1:4) { assign(paste('b',i,sep=''),eval(parse(text=paste('b',i-1,sep='' } First, b1 is set to b0 Then, b2 is set to b1 (which was just set to b0) Then, b3 is set

[R] eval and assign in loop problem

2010-07-09 Thread S.Nicholas
deaR useRs, I am trying to assign different values to different objects in a for loop. The following is a toy example of the part that has been giving me a hard time. The first "for loop" generates four objects, b0, b1, b2, b3 with random numbers. And, the second "for loop" is equivalent to b1 =