1

I'm trying to use for the first time animation package in R.

I'm using this simple code:

saveGIF({
    for (i in 1:10) plot(runif(10), ylim = 0:1)
})

But R shows this error (that i've translated in english):

Executing: 
"convert" -loop 0 -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png
    Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png
    "animation.gif"
"convert" -loop 0  -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif" is not recognized like an internal or external command,
 an executable program or batch file.
Parameter not valid - 0
an error occurred in the conversion... see Notes in ?im.convert
[1] FALSE
Warning messages:
1: running command 'C:\Windows\system32\cmd.exe /c "convert" -loop 0  -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif"' had status 1 
2: In cmd.fun(convert) :
  '"convert" -loop 0  -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif"' execution failed with error code 1
3: running command '"convert" -loop 0  -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif"' had status 4 
4: In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="animation.gif": Impossible to find the file specified

Where is the problem?

Darko
  • 1,448
  • 4
  • 27
  • 44
  • It looks like R cannot find the convert executable. The animation library needs ImageMagick to be installed. Is it on your computer ? – xraynaud Mar 20 '15 at 13:27
  • Yes, I've installed it with default settings – Darko Mar 20 '15 at 13:29
  • Is convert.exe in your PATH ? – xraynaud Mar 20 '15 at 13:32
  • While i was installing imagemagick, I have activated the flag that said :''insert un the path''. How can I see if it's True? – Darko Mar 20 '15 at 13:34
  • 1
    You have to open a console and type convert.exe in it to see if convert.exe can be found from anywhere on your computer. This consule used to be named MSDOS console in the Windows 9x years. I have no idea if this is still the case. Was R opened when you installed imagemagick ? If this is the case, you can try to close and reopen it. – xraynaud Mar 20 '15 at 13:47
  • typing convert.exe in prompt i can see a list of options for the command – Darko Mar 20 '15 at 13:49
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/73421/discussion-between-xraynaud-and-darko). – xraynaud Mar 20 '15 at 13:56

3 Answers3

4

R cannot find the convert executable. You have to specify it's full path and name using ani.option()

ani.options(convert = 'C:\\Program Files\\ImageMagick-6.9.0-Q16\\convert.exe')

(You may have to modify the 'C:\Program Files\ImageMagick-6.9.0-Q16\')

xraynaud
  • 2,028
  • 19
  • 29
1

After attempting all of these fixes as well as these and these to no success, I used alternative software to make the conversion from the png files that were successfully created with saveHTML. Several programs are described here. I am a Windows user and found the simple instructions contained in that site for VirtualDub quickly accomplished this task.

Community
  • 1
  • 1
Luke Macaulay
  • 393
  • 5
  • 14
1

I just ran into the same issue -- make sure your download of image magick includes the convert executable (convert.exe). I noticed that it wasn't included when I installed everything the first time and then after uninstalling and reinstalling, I noticed there was an unchecked option for "include legacy tools (convert)" or something to that effect. Make sure to click that box on install. Also, note that it seems to work better when you run R or RStudio as administrator.

Taylor White
  • 644
  • 5
  • 11
  • I think the newer versions of Image Magick have a magick.exe file instead of the convert.exe. It worked when I ran ani.options(convert = 'path\\magick.exe') – Jandre Marais Sep 29 '16 at 14:10