使用计时器运行连续的“demo( )”以了解事件之间的变化
假设我正在运行演示(图形),并且我想控制连续绘图的显示速度。通常,当我运行 demo(graphics)
时,我可以通过按 Enter 键来控制何时显示下一个绘图(这样可以触发 demo()
中的下一个函数)。但我不想按 Enter 键 - 我希望它自行运行,并在绘图显示之间进行时间控制的更改(例如绘图每 6 秒更改一次,3 秒后更改一次,等等)。下面是一个残酷代码,它在 2 秒后在两个 demo()
函数之间进行更改。我还使用 echo=FALSE
在快速模式中运行demo()
。但我想在一个 demo()
中做到这一点(如果可能的话,也可以在 example()
中实现)。
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需设置
before.plot.new
钩子即可添加延迟:Simply set
before.plot.new
hook to add delays: