Re: [R] HOW to Create Movies with R with repeated plot()?

From: Earl F. Glynn <efg_at_stowers-institute.org>
Date: Thu 28 Jul 2005 - 00:39:37 EST

"Jan Verbesselt" <Jan.Verbesselt@biw.kuleuven.be> wrote in message news:000e01c59293$80ee5d00$1145210a@agr.ad10.intern.kuleuven.ac.be... Dear R-helpers,

Is it possible to create a type of 'movie' in R based on the output of several figures (e.g., jpegs) via the plot() function. I obtained dynamic results with the plotting function and would like to save these as a movie (e.g., avi or other formats)?

  1. You can create animated GIFs with the caTools package.
  2. ImageMagick (clipped from R-Help) It is quite easy to do with ImageMagick (www.imagemagick.org), which can be installed on most OSes. I tried this simple sequence and it worked

beautifully.

In R:

> for(i in 1:5) {

+ jpeg(paste("fig", i, ".jpg", sep = ""))

+ hist(rnorm(100))

+ dev.off()

+ }

Then from the command line (I tried it using Linux, though it should be the

same on any platform):

% convert -delay 50 -loop 50 fig*.jpg animated.gif

This created animated.gif, a nice animation of my sequence of files. You

can control the timing of the animation by playing with -delay and -loop.

3) TCL/TK Animation (clipped from R-Help)

The tcltk package also has ways of doing this kind of stuff:

 library(tcltk)

 f <- function(){plot(rnorm(1000)); tkcmd("after", 1000,f)}

 f()

(To stop, set f <- NULL)

efg



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 28 00:53:11 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:05 EST