Hello,
I tried to run a set of functions which need to wait for the user's input but, It is executing taking the next command line as the input. can anyone tell me how can I use the code, so that the console waits for the user to input and assign a value?
I used this command :
fun1 <- function(x)
{
x <- readline(prompt="Please choose the position on x-axis: [T/F]")
if (x=="T")
{
x<-TRUE
}
else if(x=="F"){
x<-FALSE
}else{
print("plz Enter T/F")
print(fun1())
}
return(x)
}
fun2 <- function(x)
{
x <- readline(prompt="Please choose the position on y-axis: [T/F]")
if (x=="T")
{
x<-TRUE
}else if (x=="F"){
x<-FALSE
}else{
print("plz enter T/F")
print(fun2())
}
return(x)
}
sca <- function(x)
{
x <- readline(prompt="Please enter the scale from 0 and 1: [0,1]")
x<-as.double(x)
return(x)
}
the output is when I executed:
> {p1<-print(fun1(p1));
+ p2<-print(fun2(p2));
+ s1<-print(sca(s1))};
Please choose the position on x-axis: [T/F]
[1] "plz Enter T/F"
[1] ""
Please choose the position on y-axis: [T/F]
> {p1<-print(fun1(p1));
+ p2<-print(fun2(p2));
+ s1<-print(sca(s1))}
Please choose the position on x-axis: [T/F]
[1] "plz Enter T/F"
[1] ""
Please choose the position on y-axis: [T/F]f
[1] "plz enter T/F"
[1] "f"
Please enter the scale from 0 and 1: [0,1]