That's the general way to go, but the implementation needs some work: you don't want readLines, you want readline (yes, the name is similar. Yes, this is dumb. R is filled with silly things ;).
What you want is something like:
UIinput <- function(){
#Ask for user input
x <- readline(prompt = "Enter X1 value: ")
#Return
return(x)
}
You probably want to do some error-handling there, though (I could provide an X1 value of FALSE, or "turnip"), and some type conversion, since readline returns a one-entry character vector: any numeric input provided should probably be converted to, well, a numeric input. So a nice, user-proof way of doing this might be...
UIinput <- function(){
#Ask for user input
x <- readline(prompt = "Enter X1 value: ")
#Can it be converted?
x <- as.numeric(x)
#If it can't, be have a problem
if(is.na(x)){
stop("The X1 value provided is not valid. Please provide a number.")
}
#If it can be, return - you could turn the if into an if/else to make it more
#readable, but it wouldn't make a difference in functionality since stop()
#means that if the if-condition is met, return(x) will never actually be
#evaluated.
return(x)
}