R Animation – Can not get easier than this… Contributions from Gurus…

 

The above animations were courtesy of the works from the fifth link, below.

Animation is building a series of images and combining them as a movie.

There are three slightly different ways to do animation. 

(1) You may use package ‘animation’.  This has built it saving facility, to save Flash, GIF, HTML pages, PDF, and Videos, such as saveSWF(), saveGIF(), saveHTML(), saveLatex(), and saveVideo().  While HTMLpages are created using the R and javascript, we need PDF creator for embedding animated graphics with in PDF.

(2) Or you can use R, statistical calculations, and lapply and plot functions, to get codes to draw the sequence of gif files. Combine them using save.gif function available in R, which in turn needs a software in your system to be installed, called, imagemagik (Windows download) – available at the bottom of the site.  Here block updates as screen shots seems to work easily.  These you do them on your own. Going through these helps you understand the foundations of animations.

This approach uses ggplot to capture varying screen shots, with out using gganimate.

(3) Or you can use gganimate to do the animation.

All the methods fundamentally use the following pseudo code approach. (this snippet is from the first reference below)

ani.fun <- function(args.for.stat.method,
args.for.graphics, …)
{
{stat.calculation.for.preparation.here}
i = 1
while (i <= ani.options(“nmax”) & other.conditions.for.stat.method) {
{stat.calculation.for.animation}
{plot.results.in.ith.step}
# pause for a while in this step
Sys.sleep(ani.options(“interval”))
i = i + 1
}

# (i – 1) frames produced in the loop
ani.options(“nmax”) = i – 1
{return.something}
}

Whatever the method you follow, there is more power in animated graphics compared to static graphics. Go animaation! 

  • key references:

GGANIMATE:



Leave a Reply

Your email address will not be published. Required fields are marked *