Module 13: Simple Animations with R

There are different formats that animations can be created in R which include GIF, HTML, LaTeX, SWF and mp4.

The code below shows the basic format for each of the calls:

saveGIF({
for (i in 1:10) plot(runif(10), ylim = 0:1)
})

This code creates an animation by generating and then compiling many graphs which is done with the function call which is a custom loop that creates individual graphs.

I used the blog post by Bryan shared to us by our professor in order to create the animation above. In his blog post he displays the necessary code and descriptions in each line describing what the code does. I found Bryan’s blog post very informative and useful for this assignment.

The animation plots the density functions of 150 draws of 100 values from a normally distributed random variable. In order to make the graph move a constant that varies based on the iteration count is added to the 100 values.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Isaac Mendez

Isaac Mendez

An Original Blog for my Visual Analytics Course