[R] Working with the Animation package in R

Spencer Graves spencer.graves at structuremonitoring.com
Thu Jul 31 23:56:29 CEST 2014

On 7/31/2014 1:16 PM, Christofer Bogaso wrote:
> Hi again,
> I am trying to create a animation with Animation package. I preferred
> to create animation with HTML file than through GIF because this
> requires additional installation of ImageMagick which is not possible
> with my system.
> So I just run following code available in help page:
> saveHTML({
>      par(mar = c(4, 4, 0.5, 0.5))
>      for (i in 1:20) {
>          plot(runif(20), ylim = c(0, 1))
>          ani.pause()
>      }
> }, img.name = "unif_plot", imgdir = "unif_dir", htmlfile =
> "random.html", autobrowse = FALSE,
>      title = "Demo of 20 uniform random numbers", description = c("This
> is a silly example.\n\n",
>          "You can describe it in more detail.", "For example, bla bla..."))
> How this code will create an HTML file in default folder with name
> random.html and underlying image files are placed in unif_dir which is
> again in the default folder.
> However my goal is to carry this entire animation package to some
> other system. As a first try I moved the unif_dir to some other
> location. However in that case, the random.html failed to work
> properly.
> I will really appreciate if someone previously worked with this
> package can help me on how I can achieve my goal.

       I can't help with "animation", but other packages might help with 
animation, depending on what you want.

             * sliderInput{shiny} includes an "animate" argument.

             * animate{raster} sequentially plots the layers of a 
RasterStack or RasterBrick* object to create a movie.

       I tried saveVideo{animate} and could not make it work to produce 
what I want.  It calls FFmpeg.  I ultimately subscribed to the FFmpeg 
help list to learn how to use that to do what I wanted. This involved 
creating sequences of png files, each potentially a little different 
from previous ones.  To make this easier, I wrote Animate{Ecfun}.  This 
latter is not yet available on CRAN but is available on R-Forge via 
install.packages("Ecfun", repos="http://R-Forge.R-project.org").  [I'm 
scheduled to talk about this on August 12 at the San Francisco Bay Area 
useR Meetup; "www.meetup.com/R-Users".]

       Hope this helps.

> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.com

More information about the R-help mailing list