what's wrong with my while loop code in R? : <p>I want to using while loop in R.</p>

<p>I want to repeat loop until evt>1 and cpr>0, but it doesn't work.</p>

<p>work_f is function of generating numbers.</p>

<pre><code>if((evt&gt;1)&amp;&amp;(cpr&gt;0)){
work&lt;-work[order(work$z),]
obs&lt;-c(1:length(work$z))
work&lt;-cbind(work,obs)
  } else {
 while((evt&gt;1)&amp;&amp;(cpr&gt;0)) {
  j&lt;-j+1
  seed&lt;-settings*1000+h+j     

  work_f(studysize = studysize,beta=beta,cutpoint = cutpoint,settings = settigns,p=p,alpha = alpha)

  evt&lt;-data.frame(ftable(work$event))
  evttr&lt;-data.frame(evt=numeric(1),cpr=numeric(1),csr=numeric(1))
  if (p==0) {
    evttr$evt&lt;-evt$Freq[1]; evttr$cpr&lt;-evt$Freq[2]; evttr$csr&lt;-0
  }else {
    evttr$evt&lt;-evt$Freq[2]; evttr$cpr&lt;-evt$Freq[3]; evttr$csr&lt;-evt$Freq[1]
  }
  evttr[is.na(evttr)]&lt;-0
  evt&lt;-as.numeric(evttr$evt); cpr&lt;-as.numeric(evttr$cpr)

  if((evt&gt;1)&amp;&amp;(cpr&gt;0)){
    work&lt;-work[order(work$z),]
    obs&lt;-c(1:length(work$z))
    work&lt;-cbind(work,obs)
  }
 }
} 
</code></pre>

<p>What's wrong?</p>
