[R] R interactive input like C++
eriki at ccbr.umn.edu
Thu Apr 15 03:22:17 CEST 2010
David Scott wrote:
> Erik Iverson wrote:
>> ?? wrote:
>>> Thank you for your reply.
>>> My objective is simple. Assume I have a constant vector, say Vector.
>>> in C++ code, I want to do:
>>> int index;
>>> cout<<"Please enter the index of the element you want to look at
>>> Vector :";
>>> I want every user to be able to do this.
>>> As I understand, scan can only read data from a fixed file. Can I
>>> just get the input from the shell directly?
>> Isn't that what the file argument of ?scan says? I think?
>> file: the name of a file to read data values from. If the
>> specified file is ‘""’, then input is taken from the keyboard
>> (or whatever ‘stdin()’ reads if input is redirected or R is
> I think the required function is readline which prompts for user input.
Great, didn't know that one. The example in ?readline is hilarious.
More information about the R-help