quant
quant

Reputation: 4482

creating a GIF in R error

I would like to learn how to create a simple GIF. I found this code :

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()

which creates 11 png images. I would like to create a GIF file from these 11 eleven images, so I am using system("convert -delay 80 *.png example_1.gif"). But I get an error

> 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

I have also looked at Creating a Movie from a Series of Plots in R; but this does not work for me either.

P.S. I have already installed ImageMagick

Upvotes: 0

Views: 361

Answers (1)

Jeremy Voisey
Jeremy Voisey

Reputation: 1297

Try running system("convert /?") to see the source of your problem!!!

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.

If you have version 7 of ImageMagick installed,then this line should solve the problem.

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

enter image description here

Upvotes: 1

Related Questions