"R" you ready?, and kindly contributed to Want to share your content on R-bloggers? [This article was first published on, and kindly contributed to R-bloggers ]. (You can report issue about the content on this page here Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The first week of April I attended an excellent workshop on biplots held by Michael Greenacre and Oleg Nenadić at the Gesis Institute in Cologne, Germany. Throughout his presentations, Michael used animations to visualize the concepts he was explaining. He also included animations in some of his papers. This inspired me to do this post in which I will show how to use LaTex, R and Sweave to include animations in a PDF document. Here is the PDF document we will create (on MacOS the standard PDF viewer may not be able to play the animations, but Adobe Reader will). For this post some basic knowledge about Sweave is assumed.

First, let’s create a simple animation in R. I will use a neat example Oleg used during the biplot workshop: Pacman eating. Herefore we need a pacman. We use a pie chart to construct him

pie(c(.1, .9, .1) # a pie chart pie(c(.1, .9, .1), # a pie chart col=c("white", "yellow", "white"), # resembling pac man border=NA, labels=NA) points(.3,.4, pch=16, cex=4) # adding an eye

Next, we will produce a series of pictures of Pacman by varying a parameter that specifies how far he opens his mouth. Here, all the single pics are saved in one PDF file, each as one page.