动画包中saveGIF命令的错误

时间:2015-03-20 12:04:43

标签: r animation gif

我正试图在R。

中第一次使用animation

我正在使用这个简单的代码:

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

但是R显示了这个错误(我用英语翻译过):

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

问题出在哪里?

3 个答案:

答案 0 :(得分:4)

R无法找到转换可执行文件。您必须使用ani.option()

指定它的完整路径和名称
ani.options(convert = 'C:\\Program Files\\ImageMagick-6.9.0-Q16\\convert.exe')

(您可能需要修改' C:\ Program Files \ ImageMagick-6.9.0-Q16 \')

答案 1 :(得分:1)

尝试所有这些修补程序以及thesethese都没有成功后,我使用了替代软件从使用saveHTML成功创建的png文件进行转换。描述了几个程序here。我是Windows用户,发现VirtualDub网站中包含的简单说明很快完成了这项任务。

答案 2 :(得分:1)

我刚遇到同样的问题 - 请确保您下载的图片magick包含convert executable(convert.exe)。我注意到,当我第一次安装所有内容并且卸载并重新安装后,它没有被包含在内,我注意到有一个未经检查的选项,包括传统工具(转换)"或者那种效果。确保在安装时单击该框。另外,请注意,当您以管理员身份运行R或RStudio时,它似乎工作得更好。

相关问题