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 :";
cin>>index
cout<<Vector[index]


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
           embedded).


I think the required function is readline which prompts for user input.

?readline


David Scott


_________________________________________________________________
David Scott     Department of Statistics
                The University of Auckland, PB 92019
                Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to