I was able 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 it from the terminal using the below code, it just goes to the next line without taking user input. How do I overcome this?
word <- readline(prompt="Enter a word: ")
print(word);