title: Error: missing value where TRUE/FALSE needed in while loop
body: <p>I am trying to write a program using a while loop:</p>
  
  <pre><code>n=50
  sum=array(0,n)
  sum[1]=0
  for(k in 1:n)
  {
     sum[k+1]=sum[k]+k
     while((sum[k+1]-sum[k])&lt;10)
     {
        print(sum[k+1])
        k=k+1
     }
  }
  sample=data.frame(Sum=sum) sample
  </code></pre>
  
  <p>its showing: </p>
  
  <pre><code>Error in while ((sum[k + 1] - sum[k]) &lt; 10) { : 
    missing value where TRUE/FALSE needed
  </code></pre>
  
  <p>Can anyone tell what is wrong with this code?</p>