[R] Wait for keystroke or timeout

Prof. John C Nash nashjc at uottawa.ca
Fri May 28 01:08:36 CEST 2010

I would like to have a function that would wait either until a specified timeout (in
seconds preferably) or until a key is pressed. I've found such a function quite useful in
other programming environments in setting up dialogs with users or displaying results,
rather like a timed slideshow that can be speeded up by hitting a key.

Searching R-seek has led to wait() in the package 'audio', but when I try, for example,

    joe<-wait(readline("hit a key to continue"), timeout=6)

I am forced to wait the full timeout.

Probably someone has done this before and I'm just not using the right search terms.
Suggestions welcome.

Thanks in advance.


More information about the R-help mailing list