error in saveGIF command in animation package

2019-01-29 05:42发布

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?

标签: r animation gif
3条回答
The star\"
2楼-- · 2019-01-29 06:26

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.

查看更多
Lonely孤独者°
3楼-- · 2019-01-29 06:28

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\')

查看更多
混吃等死
4楼-- · 2019-01-29 06:37

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.

查看更多
登录 后发表回答