The trio: animation, ggplot and ImageMagick for R version 3.5.0

Hello, try to run a script where I use the libraries animation and ggplot2. But I get the following notice:

I cannot find ImageMagick with convert = "convert"
Warning messages:
1: In system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
  running command 'C:\WINDOWS\system32\cmd.exe /c convert --version' had status 4
2: In find_magic() : ImageMagick not installed yet!
3: In im.convert(img.files, output = path.expand(, convert = convert,  :
  Please install ImageMagick first or put its bin path into the system PATH variable

when trying to install the library, the system informs me the following:

install.packages("ImageMagick", dependencies = TRUE, repos = "")
Warning in install.packages :
  package ‘ImageMagick’ is not available (for R version 3.5.0)

What to do?

1 Like

Please install ImageMagick first or put its bin path into the system PATH variable

This refer to a System Requirement not a missing package. {animation} :package: needs the utility ImageMagick or another, as stated in the cran help page

SystemRequirements: ImageMagick ( or GraphicsMagick ( or LyX ( for saveGIF(); (PDF)LaTeX for saveLatex(); SWF Tools ( for saveSWF(); FFmpeg ( or avconv ( for saveVideo()

You should install the windows binary for the package to work.

About animation of ggplot2 graphs, there are also a combination of {gganimate} and {magick} that could do the trick. {magick} :package: use c++ imagemagick so with windows binary there is no system dependency.
An example from this post: rOpenSci | Magick 1.0: 🎩 ✨🐇 Advanced Graphics and Image Processing in R

img <- image_graph(res = 96)
datalist <- split(gapminder, gapminder$year)
out <- lapply(datalist, function(data){
  p <- ggplot(data, aes(gdpPercap, lifeExp, size = pop, color = continent)) +
    scale_size("population", limits = range(gapminder$pop)) +
    scale_x_log10(limits = range(gapminder$gdpPercap)) +
    geom_point() + ylim(20, 90) +  ggtitle(data$year) + theme_classic()
animation <- image_animate(img, fps = 2)
image_write(animation, "animation.gif")