动画包中的 saveGIF 命令出错
error in saveGIF command in animation package
我第一次尝试在 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
问题出在哪里?
R 找不到转换可执行文件。您必须使用 ani.option()
指定它的完整路径和名称
ani.options(convert = 'C:\Program Files\ImageMagick-6.9.0-Q16\convert.exe')
(您可能需要修改 'C:\Program Files\ImageMagick-6.9.0-Q16\')
在尝试了所有这些修复之后 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 很快完成了这个任务。
我只是 运行 遇到了同样的问题 -- 确保您下载的 image magick 包含转换可执行文件 (convert.exe)。我注意到当我第一次安装所有东西时它没有包括在内,然后在卸载并重新安装后,我注意到 "include legacy tools (convert)" 或类似的东西有一个未选中的选项。确保在安装时单击该框。另外,请注意,当您 运行 R 或 RStudio 作为管理员时,它似乎工作得更好。
我第一次尝试在 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
问题出在哪里?
R 找不到转换可执行文件。您必须使用 ani.option()
ani.options(convert = 'C:\Program Files\ImageMagick-6.9.0-Q16\convert.exe')
(您可能需要修改 'C:\Program Files\ImageMagick-6.9.0-Q16\')
在尝试了所有这些修复之后 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 很快完成了这个任务。
我只是 运行 遇到了同样的问题 -- 确保您下载的 image magick 包含转换可执行文件 (convert.exe)。我注意到当我第一次安装所有东西时它没有包括在内,然后在卸载并重新安装后,我注意到 "include legacy tools (convert)" 或类似的东西有一个未选中的选项。确保在安装时单击该框。另外,请注意,当您 运行 R 或 RStudio 作为管理员时,它似乎工作得更好。