简体   繁体   English

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

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

I am trying to use 'animate' package of R 3.1.3 in RStudio 0.98.1102 in a Windows 7 computer. 我正在尝试在Windows 7计算机的RStudio 0.98.1102中使用R 3.1.3的“动画”包。 I have already installed ImageMagick and if I write the following lines, I get an animated gif file. 我已经安装了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")

So far so good. 到现在为止还挺好。 But I face problems when I try to use gganimate package. 但是,当我尝试使用gganimate软件包时会遇到问题。 I have just copied the following lines from the github page of animation package: 我刚刚从动画包的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)

After the last line is executed, I get the following error: 执行最后一行后,出现以下错误:

error message 1 错误消息1

Now, I write the following command and run again to get a similar error message and no gif file is produced: 现在,我编写以下命令,然后再次运行以获取类似的错误消息,并且不会生成gif文件:

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

Now if I write the lines below, I get error message but an animated gif file is produced. 现在,如果我写下面的代码行,则会收到错误消息,但会生成一个动画gif文件。

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

error message 3 错误消息3

The animation is not shown in RStudio, I had to find the location of the working directory where the new gif file is saved. 该动画未在RStudio中显示,我必须找到保存新gif文件的工作目录的位置。

I don't understand why is this happening and how to use gganimate() to generate .gif (inside RStudio) without any error message being generated. 我不明白为什么会这样,以及如何使用gganimate()生成.gif(在RStudio内部)而没有生成任何错误消息。 I will highly appreciate your feedback, suggestions, solutions to the above mentioned issues. 非常感谢您对上述问题的反馈,建议和解决方案。

The code works for me. 该代码对我有用。 Did you install ImageMagick? 您安装了ImageMagick吗? It's needed for gganimate See here for instructions: https://rpubs.com/sjackman/gapminder-gganimate gganimate需要它,请参见此处以获取指示: https : gganimate

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

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