I managed to wait for user input in R when running my script as Rscipt myscript.R from the command line as follows and reading the input from stdin.
cat("Enter word : ")
word <- readLines(file("stdin"),1)
print(word);
However, when I try to do this from the terminal using the code below, it simply moves on to the next line without user input. How can I overcome this?
word <- readline(prompt="Enter a word: ")
print(word);
source
share