Animated Statistics Using R (to be moved to AniWiki!)
The package "animation" provides various animations in statistics.

I have been studying in the major of statistics for more than 5 years (and there are still at least 3 years left), and I find one significant difference between the disciplines of pure mathematics and statistics: usually statistics can be imagined in a very practical way, while it is not true for mathematics. For example, I believe everyone can imagine why k-Nearest Neighbor technique works, but not everyone can imagine why Taylor expansion technique works although we can prove it!

Thus I wrote such a package: just for better understanding of statistical techniques and data analysis.


This package "animation" is available in CRAN now; the source code as well as Windows binary can be downloaded at:

You may install by R CMD INSTALL after downloading the source or simply use install.packages() in R:


I have written a vignette Vignette for 'animation' for this package explaining some details for animations in statistics, and this vignette is also an animation gallery (see Chapter 5).


Running animations either inside R (in graphical devices) or outside R (in HTML pages) are OK, as I provided an argument saveANI (actually in the argument control using the function ani.control()) to decide whether to save PNG files.

By ani.start(), specifying saveANI = TRUE, and ani.stop(), you can generate an HTML page containing the animation; or if saveANI = FALSE, the animations will be shown inside R graphical devices.

For further information, please check the help pages or the vignette.


For example, to create HTML animation pages, just use ani.start() and ani.stop(), otherwise if you just want to watch animations inside R, please check those animation functions such as brownian.motion(), cv.ani(), kmeans.ani(), knn.ani(), etc.

Please make sure R has write permission to your disk when saving animations (saveANI = TRUE).

I'll explain every animation function in the vignette (Chapter 5) as well as in this site.