title: R loop until condition is met
body: <p>Working on a project in R, I got stuck somewhere.
  Those are my data:</p>
  <pre><code>
  r &lt;- 0.001
  a &lt;- 0.386
  b &lt;- 0.799
  
  yp &lt;- b*df$x+a
  sse &lt;- ((df$y-yp)^2)*0.5
  a &lt;- a-r*sum(-(df$y-yp))
  b &lt;- b-r*sum(-(df$y-yp)*df$x)
  
  </code></pre>
  <p>How can I find the number of iterations until SSE error is 0.0001?</p>