简体   繁体   中英

'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. I have already installed ImageMagick and if I write the following lines, I get an animated gif file.

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. I have just copied the following lines from the github page of animation package:

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

Now, I write the following command and run again to get a similar error message and no gif file is produced:

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.

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

error message 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.

I don't understand why is this happening and how to use gganimate() to generate .gif (inside RStudio) without any error message being generated. I will highly appreciate your feedback, suggestions, solutions to the above mentioned issues.

The code works for me. Did you install ImageMagick? It's needed for gganimate See here for instructions: https://rpubs.com/sjackman/gapminder-gganimate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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