I am trying to figure out, how can i run an r script, using Rscript
in windows command prompt and ask for user input.
So far, i have found answers on how do ask for user input in R's interactive shell. Any effort in doing the same with readline()
or scan()
has failed.
example:
I have a polynomial y=cX
where X
can take more than one values X1
,X2
,X3
and so on. C
variable is know, so what i need in order to calculate the value of y
is to ask the user for the Xi
values and store them somewhere inside my script.
Uinput <- function() {
message(prompt"Enter X1 value here: ")
x <- readLines()
}
Is this the way to go? Any additional arguments? Will as.numeric
help? How do i return X1
? And will the implementation differ depending on the OS?
Thanks.