0

我是 R 新手并尝试使用动画包。从手册中,我尝试运行此代码段

library(animation)
oopt = ani.options(interval = 0.2, nmax = 10)
## use a loop to create images one by one
for (i in 1:ani.options("nmax")) {
  plot(rnorm(30))
  ani.pause() ## pause for a while (’interval’)
}
## restore the options
ani.options(oopt)

但我得到了错误:

Error in ani.options(oopt) : object 'oopt' not found

我已经安装了包,我使用的是 2.14.2 版

4

1 回答 1

2

RStudio 可以逐行评估您的代码:Ctrl-Enter 运行源代码中光标处的行。您可以在源代码下方的控制台中看到,在这种情况下,只会评估一行。要运行完整的脚本,请使用“全部运行”(Ctrl-Shift-R)。

除了从源代码窗口运行之外,您还可以直接输入一行代码并按 Enter 对其进行评估。

于 2012-04-02T09:58:47.180 回答