[R] Odp: Pausing script to allow user input from keyboard.

Petr PIKAL petr.pikal at precheza.cz
Mon Aug 9 09:55:02 CEST 2010


Hi

you are right. From ?scan default value for imput value is double, so you 
need to specify that it shall be character. I just showed possible 
solution not a solution which can be used in all imaginable cases.

Regards
Petr

r-help-bounces at r-project.org napsal dne 07.08.2010 05:20:56:

> I'm having problems with your method Petr.  I seem to get an additional 
prompt.
> 
> Example...
> f <- function() {
>   cat("\n", "Enter a string:", "\n")
>   s <- scan(n=1)
>   cat("\n", "You entered", s, "\n")
> }
> 
> Running f() produces...
> 
>  Enter a string:
> 1: blah
> 1:
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, 
na.strings,  :
>   scan() expected 'a real', got 'blah'
> >
> 
> Changing the code to
>    scan(n=1, what="character")
> Fixes the problem but your post implies that this is not necessary.
> 
> Could it be GUI specific ? I am running R 2.11.1 with the Mac OSX GUI
> 1.34 Leopard build 64-bit (5589)
> 
> Michael
> 
> ______________________________________________
> 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