Break loop with keyboard input (R)
<p>I need an R loop to continue running until the user presses a key. Something like the below. Any ideas? I'm new to R</p>

<pre><code>while(FALSE_after_user_input){
  queryWebApi()
  Sys.sleep(1)
}
</code></pre>

<p><strong>EDIT 1</strong></p>

<p>What I'm really after is a way to stop data collection. I have a function I want to run every few seconds to query new data. The user needs the ability to stop the data collection loop.</p>

<p>readline() doesn't work as it halts execution of the data collection loop</p>