Lets say I am running demo(graphics)
and I want to control the speed with which consecutive plots are displayed. Normally when I run demo(graphics)
I can control when the next plot will display by pressing enter (and this way triggering next function in demo()
). But I don't want to press enter - I want it to run on its own, with the time-controlled changes between plot displays (for example the plot would change every 6 seconds, next after 3 seconds, etc.). Below is a brutal code that changes between two demo()
functions after 2 seconds. I also run demo()
in quick-mode using echo=FALSE
. But I would like to do that WITHIN a single demo()
(and for the example()
too if possible).
library(tcltk2)
test1 <- function() demo(graphics,echo=F)
test2 <- function() demo(lm.glm, package="stats",echo=F)
tclTaskSchedule(2000, test1())
Sys.sleep(2)
tclTaskSchedule(2000, test2())
Sys.sleep(2)
Simply set before.plot.new
hook to add delays:
setHook("before.plot.new", function(...) Sys.sleep(1))
demo(graphics, ask=F)