title: Execute R Script that asks for and incorporates user prompts
body: <p>I am developing an R script in RStudio that requires the user to input two values (a first name and a last name).  These inputs will later be used for pattern matching of a text document.</p>
  
  <p>In Python, raw_input would be used to gather these values and I understand that readline(prompt = ) is the associated function in R, but I cannot seem to have my script stop to ask for a value.  Instead it appends the next line of code.</p>
  
  <p>My function to prompt the user for names is:</p>
  
  <pre><code>askForName &lt;- function(firstOrLast){
    if(firstOrLast == "first"){
      x &lt;- readline(prompt = "Enter first name: ")
    }
    else if(firstOrLast == "last"){
      x &lt;- readline(prompt = "Enter last name: ")
    }
    return(x)
  }
  </code></pre>
  
  <p>When I run:</p>
  
  <pre><code>firstName &lt;- askForName("first")
  lastName &lt;- askForName("last")
  </code></pre>
  
  <p>The console returns:</p>
  
  <pre><code>&gt; firstName &lt;- askForName("first")
  Enter first name: lastName &lt;- askForName("last")
  </code></pre>
  
  <p>How can I get R to wait for a user-inputted value before proceeding through the script?</p>