Creating animated graphics can be interesting to present your data. A famous example is the Hans Rosling’s talk concerning countries evolution. There are several
way to do it with R. All solutions relies on the same method: creating several images and transform them to a .gif using ImageMagick. Here are a few
Image Magick is a software that allows to work with images using command lines. You can create and output a set of images doing a loop in R. Then, give all these images to Image magick and it will convert them into a .gif format.
The gganimate library is a ggplot2 extension created by David Robinson that allows to easily create animation from your data. Basically it allows to use the frame (the step in the animation) as another aesthetic.
The tweenR library by Thomas Lin Pedersen allows to interpolate your data between different states. It is particularly handy for animation since it allows to go from one state to another using a multitude of images, thus making a smooth animation. Once you have interpolated your data, you can use gganimate or imagemagick to create your animation as shown above.