title: How to flush the print buffer in R?
body: <p>I want to run a long-running simulation and have updates printed periodically. However, I am finding that my <code>print</code> statements are being buffered, even when I explicitly try to <code>flush</code>. Here, for example:</p>
  
  <pre><code>for (i in 1:10)
  {
      print(i)
      flush(stdout())
      Sys.sleep(1)
  }
  </code></pre>
  
  <p>I would expect this to increment every 1sec, but it outputs everything at the end, after 10 seconds. </p>
  
  <p>How would you force a flush of the print buffer?</p>