在 R 错误中创建 GIF

creating a GIF in R error

我想学习如何制作简单的 GIF。 我找到了这段代码:

dir.create("examples")
setwd("examples")

# example 1: simple animated countdown from 10 to "GO!".
png(file="example%02d.png", width=200, height=200)
for (i in c(10:1, "G0!")){
  plot.new()
  text(.5, .5, i, cex = 6)
}
dev.off()

创建 11 张 png 图像。我想用这 11 张 11 张图片创建一个 GIF 文件,所以我使用 system("convert -delay 80 *.png example_1.gif")。但是我得到一个错误

> system("convert -delay 80 *.png example_1.gif")
  Invalid Parameter - 80
  Warning message:
  running command 'convert -delay 80 *.png example_1.gif' had status 4

我也看过Creating a Movie from a Series of Plots in R;但这对我也不起作用。

P.S。我已经安装了 ImageMagick

尝试 运行 system("convert /?") 查看问题的根源!!!

Converts a FAT volume to NTFS.

CONVERT volume /FS:NTFS [/V] [/CvtArea:filename] [/NoSecurity] [/X]


  volume      Specifies the drive letter (followed by a colon),
              mount point, or volume name.
  /FS:NTFS    Specifies that the volume will be converted to NTFS.
  /V          Specifies that Convert will be run in verbose mode.
  /CvtArea:filename
              Specifies a contiguous file in the root directory
              that will be the place holder for NTFS system files.
  /NoSecurity Specifies that the security settings on the converted
              files and directories allow access by all users.
  /X          Forces the volume to dismount first if necessary.
              All open handles to the volume will not be valid.

如果您安装了 ImageMagick 版本 7,那么这行应该可以解决问题。

system("magick -delay 80 *.png example_1.gif")