繁体   English   中英

R中的“动画”包保存状态为127的GIF

[英]'animation' package in R saves GIF with status 127

我正在尝试在Windows 7计算机的RStudio 0.98.1102中使用R 3.1.3的“动画”包。 我已经安装了ImageMagick,如果我写了以下几行,就会得到一个动画的gif文件。

library(animation)
ani.options('C:/Program Files/ImageMagick-7.0.4-Q16/convert.exe')
png(file="example%02d.png",width=200, height=200)
for(i in c(10:1,"GO!")){
    plot.new()
    text(.5,.5,i,cex=6)
}
dev.off()
system("magick -delay 80 *.png example_1.gif")

到现在为止还挺好。 但是,当我尝试使用gganimate软件包时会遇到问题。 我刚刚从动画包的github页面复制了以下几行:

library(gapminder)
library(ggplot2)
theme_set(theme_bw())
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = 
continent, frame = year)) +
geom_point() +
scale_x_log10() 
library(gganimate)
gganimate(p)

执行最后一行后,出现以下错误:

错误消息1

现在,我编写以下命令,然后再次运行以获取类似的错误消息,并且不会生成gif文件:

ani.options(convert = shQuote('C:/Program Files/ImageMagick-7.0.4-
Q16/magick.exe'))
gganimate(p)

现在,如果我写下面的代码行,则会收到错误消息,但会生成一个动画gif文件。

ani.options(convert = shQuote('C:/Program Files/ImageMagick-7.0.4-
Q16/magick.exe'))
gganimate(p, "output.gif")

错误消息3

该动画未在RStudio中显示,我必须找到保存新gif文件的工作目录的位置。

我不明白为什么会这样,以及如何使用gganimate()生成.gif(在RStudio内部)而没有生成任何错误消息。 非常感谢您对上述问题的反馈,建议和解决方案。

该代码对我有用。 您安装了ImageMagick吗? gganimate需要它,请参见此处以获取指示: https : gganimate

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM