title: How do I get user input when in R console
body: <p>How do I get user input from the terminal?
  I write my R program in Notepad then copy it into R Console to run.  My program needs user input.
  If I use readline it does not pause for user input but picks up the following line of 'code' as its response.
  Similarly with cat or cat &amp; scan whether they are used within functions or in-line.
  Example:    (the xxread1:4 are there to stop the program producing errors)</p>
  
  <pre><code>read_message=function()
     {xx&lt;-readline('does it appear? ')}
  readkey &lt;- function()
     {cat("[press [enter] to continue]")
       number &lt;- scan(n=1,what='character')}
  x=read_message()
  xrread1='1'
  x=readline(prompt='Is it real? ')
  xrread2='2'
  gh=readkey()
  xrread3='3'             
  cat("[enter field]")
  number &lt;- scan(n=1,what='character')
  xrread4='4'
  number
  </code></pre>
  
  <p>I know this does not look like valid code, but run it -- it works but
  does not pause for user input, the results of the reads,etc are the following numbers.
  So how do I get user input?</p>