[R] Getting scan() -command to work during the program run

Bert Gunter bgunter.4567 at gmail.com
Tue Dec 20 16:19:42 CET 2016


??

> f <- function() {X <- scan(n =1); X}
> f()
1: 3
Read 1 item



-- Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Dec 20, 2016 at 12:37 AM, Atte Tenkanen <attenka at utu.fi> wrote:
> Hi,
>
> How to get scan(file="") command to ask my input from the keyboard?
>
> If I put the command straight to the console it works
>
>> X1 <- scan(n=1)
> 1: 22
> Read 1 item
>
> but as a part of a program it just continues without asking my value?
>
>> X1 <- scan(n=1)
> 1:
> Read 0 items
>
> Yours,
>
> Atte Tenkanen
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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