[R] how to get character from keyboard when run a file
Greg.Snow at imail.org
Sun Sep 11 03:43:36 CEST 2011
Are you running a script using 'source' or in batch mode? And do you want the script to get input from a user instead of from the script? If that is the case then you need to work a little harder because R assumes that if you are running in a non-interactive mode (source and batch mode) that it should not expect interaction and so tries to get the input from other sources. You probably could use the tcltk package to pop up a window to ask for information and have the script wait until the information is provided before continuing, but be very careful, if you ever try to run the script completely non-interactive and you have not planned a way to tell it find the information a different way then you could have problems.
Another approach is to wrap the entire script in a function, then run the function interactively instead of in batch mode, then the standard tools for getting information from the user will work.
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of bebece
Sent: Saturday, September 10, 2011 9:17 AM
To: r-help at r-project.org
Subject: [R] how to get character from keyboard when run a file
when run a R file, i can get numeric by scan(), but scan() can't read
character or i make a wrong.
so how can i get character from keyboard when i run a R file?
View this message in context: http://r.789695.n4.nabble.com/how-to-get-character-from-keyboard-when-run-a-file-tp3803944p3803944.html
Sent from the R help mailing list archive at Nabble.com.
R-help at r-project.org mailing list
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