Reputation: 107
I created a script where the user is initially asked to enter some inputs that are assigned to variables. However, when you launch the script, R does not wait for the user to enter input to perform operations. How do I tell R to wait for the user's input before the script starts? Actually my code looks like:
fun <- function(){
x <<- readline("What is the value of x?")
y <<- readline("What is the value of y?")
z <<- readline("What is the value of z?")
}
fun()
#BEGIN OF THE SCRIPT USING X, Y, Z
Upvotes: 0
Views: 1816
Reputation: 1975
Assign the input to variables this way.
fun <- function(){
readline("What is the value of x?") ->> x
readline("What is the value of y?") ->> y
readline("What is the value of z?") ->> z
return (z)
}
Now, call your function, but wrap it in an expression if you want to take input from the keyboard...
{
fun()
library(httr)
# this is a comment
}
Upvotes: 2