[R] R interactive input like C++
Lukas Schefczyk
Rlist at mschefczyk.de
Thu Apr 15 03:06:56 CEST 2010
?readline
HTH
Lukas Schefczyk
--------------------------------------------------
From: "??" <yuuniverse4444 at gmail.com>
Sent: Thursday, April 15, 2010 2:40 AM
To: "Erik Iverson" <eriki at ccbr.umn.edu>
Cc: <r-help at r-project.org>
Subject: Re: [R] R interactive input like C++
> 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?
>
> Thanks
>
>
>
>
> 2010/4/14 Erik Iverson <eriki at ccbr.umn.edu>
>
>> ?? wrote:
>>
>>> Hi,
>>>
>>> Does R have some way to function as the cin object in C++
>>>
>>> like I generate a integer variable x in R, and I want the user to input
>>> the
>>> value x, like in C++
>>>
>>> cin>>x
>>>
>>>
>> See ?scan
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list