Displaying 2 results from an estimated 2 matches for "choosefunct".
Did you mean:
choosefun
2007 May 23
1
Readline - wait for user input
...t get the code
right.
If I run the following code one line at a time, it works fine. If I run
it together as a block, however, it doesn't wait for the input and gives
an error.
There must be a way to have are pause/wait for an answer, but I can't
seem to find it. Thanks! J
Code:
choosefunction <- function(){readline("1. linear, 2. linear with lag, 3.
nonlinear ")}
ans <- as.integer(choosefunction())
if (ans==1){K2=x1}
if (ans==2){K2=x2 }
if (ans==3){K2=x3 }
ans
Error text:
> ans <- as.integer(choosefunction())
1. linear, 2. linear with lag, 3. nonlinear if (an...
2007 Jun 18
1
Readline
...for the input
and gives
>> >> an error.
>> >>
>> >> There must be a way to have are pause/wait for an answer, but I
can't
>> >> seem to find it. Thanks! J
>> >>
>> >> Code:
>> >>
>> >> choosefunction <- function(){readline("1. linear, 2. linear with
lag, 3.
>> >> nonlinear ")}
>> >> ans <- as.integer(choosefunction())
>> >> if (ans==1){K2=x1}
>> >> if (ans==2){K2=x2 }
>> >> if (ans==3){K2=x3 }
>> >>...