title: User input in R
body: <p>I am trying to run an R script, using <code>Rscript</code> in Windows command prompt and ask for user's input.</p>
  
  <p>So far, i have found answers on how to implement something similar in R's interactive shell. <code>readline()</code> or <code>scan()</code> doesn't seem to work for the command prompt.</p>
  
  <p>Examples:</p>
  
  <p>I have a polynomial <code>y=cX</code> where <code>X</code> can take more than one values <code>X1</code>,<code>X2</code>,<code>X3</code> and so on. <code>C</code> variable is know,  so what i need in order to calculate the value of <code>y</code> is to ask the user for the <code>Xi</code> values and store them somewhere inside my script.</p>
  
  <p>The script bellow does nothing.</p>
  
  <pre><code>UIinput &lt;- function(){
  
      #Ask for user input
      x &lt;- readline(prompt = "Enter X1 value: ")
  
      #Return
      return(x)
  }
  </code></pre>
  
  <p>The second example below just prompts the message and then ends.</p>
  
  <pre><code>FUN &lt;- function(x) {
  
      if (missing(x)) {
          message("Uhh you forgot to eneter x...\nPlease enter it now.")
          x &lt;- readLines(n = 1)
      }
      x
  }
  FUN()
  </code></pre>
  
  <p>Console output:</p>
  
  <pre><code>Uhh you forgot to eneter x...
  Please enter it now.
  character(0)
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Thanks in advance</p>