1

I'm trying to run multiple user inputs using readline in an R script.

The point is to ask 2 consecutive questions to a user and create 2 vectors with the answers A and B.

Then I need A and B to be used in a function subsequently.

A <- readline(prompt = "Question 1?: ") 

B <- readline(prompt = "Question 2?: ")  

Between question 1 and question 2 ,I guess I should introduce any conditional that when I source the script file, the system waits for the answer to question 1, then proceed with question 2 and then proceed with the rest of the script with A and B vectors created and ready to be used.

The problem is when I source the script it reads both questions at the same time.

Question 1 and 2 are mandatory to proceed and are independent questions non related one to another.

Answer to question 1 should be letters (a-z) no limit

Answer to question 2 should be numeric (0-9) max. 4 digits

Any comments will be highly appreciated.

Thanks for your time all.

Rick
  • 171
  • 1
  • 13
  • 1
    Related: https://stackoverflow.com/questions/44012056/r-how-do-i-prompt-the-user-for-input-from-the-console – MrFlick Jun 12 '18 at 15:07
  • 3
    Possible duplicate of [R: how do I prompt the user for input from the console?](https://stackoverflow.com/questions/44012056/r-how-do-i-prompt-the-user-for-input-from-the-console) – Bernhard Jun 12 '18 at 15:17

0 Answers0