Re: [R] problem with break command

2012-04-26 Thread Petr Savicky
On Thu, Apr 26, 2012 at 02:49:08PM -0500, cassie jones wrote: > Thanks Berend, you are right. The break command would not work here. But > the while loop is taking time to generate the desired. > > On Thu, Apr 26, 2012 at 2:39 PM, Berend Hasselman wrote: [...] > > You need a while loop for this.

Re: [R] problem with break command

2012-04-26 Thread Petr Savicky
On Thu, Apr 26, 2012 at 02:30:09PM -0500, cassie jones wrote: > Hello R-users, > > I am having a problem with the 'break' command in R. I am wondering if > anyone can help me out with this. My program is similar to the following. > > a=rep(NA,5) > a[1]=0 > for(i in 2:5) > { > a[i]=a[i-1]+runi

Re: [R] problem with break command

2012-04-26 Thread cassie jones
Thanks Berend, you are right. The break command would not work here. But the while loop is taking time to generate the desired. On Thu, Apr 26, 2012 at 2:39 PM, Berend Hasselman wrote: > > On 26-04-2012, at 21:30, cassie jones wrote: > > > Hello R-users, > > > > I am having a problem with the 'b

Re: [R] problem with break command

2012-04-26 Thread Berend Hasselman
On 26-04-2012, at 21:30, cassie jones wrote: > Hello R-users, > > I am having a problem with the 'break' command in R. I am wondering if > anyone can help me out with this. My program is similar to the following. > > a=rep(NA,5) > a[1]=0 > for(i in 2:5) > { >a[i]=a[i-1]+runif(1,0,3) >if

[R] problem with break command

2012-04-26 Thread cassie jones
Hello R-users, I am having a problem with the 'break' command in R. I am wondering if anyone can help me out with this. My program is similar to the following. a=rep(NA,5) a[1]=0 for(i in 2:5) { a[i]=a[i-1]+runif(1,0,3) if(a[i]>5) { i=2 break } } What exactly I am