I want to take user input into a variable and display it on the screen. However, when I try to take the input using the readline() function it works fine sometimes but not always. Sometimes, I run into the error as below:
So, is there any other function that can take in the user input like the input() function in python.
The code which I have tried is as follows:
my.name <- readline(prompt="Enter name: ")
my.age <- readline(prompt="Enter age: ")
# convert character into integer
my.age <- as.integer(my.age)
print(paste("Hi,", my.name, "next year you will be", my.age+1, "years old."))
Could someone please help me out with this?
