In older versions of R, version 2.9 anyway, I was able to run an R program from batch using rterm.exe and create a graphics window that a user could scroll back and forth and view the graphs. I was able to do that by using some R code like:
kbd <- function(key) {
if (key == "q") { "Quit" } else NULL }
getGraphicsEvent(" ", onKeybd = kbd)
This held the graphics viewer open until the user pressed the "q" key. In newer versions of R, it seems that since this is started from batch (non-interactive using Rterm.exe), the key value is always NULL and the graphics window simply flashes and closes. My question is if there is any way I can somehow convince the R system that I'm running a quasi-interactive session and get the behavior of getGraphicsEvent to not return NULL immediately?
You can fake an interactive session in one that would be detected as non-interactive by starting Rterm with the option
--ess
on Windows, or
--interactive
on Unix-alikes.
This may cause other problems, because all functions will see the session as interactive. You can't change that flag in the middle of a session, since it affects lots of things related to I/O.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With