[R] Odp: Pausing script to allow user input from keyboard.
Michael Bedward
michael.bedward at gmail.com
Sat Aug 7 05:20:56 CEST 2010
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
More information about the R-help
mailing list