If you have a code chunk that generates multiple plots (e.g., using a loop), you can have the output stitched together in an aninmation using the fig.show=‘animate’
code chunk option.
```{r sampleani, fig.show='animate', fig.width=4, fig.height=4, cache=FALSE, interval=0.05, aniopts="controls,loop"}
for (i in 1:50) {
plot(x=i/10, y=i/10, xlim=c(0,6), ylim=c(0,6), pch=20, col=palette()[2], cex=5)
}
```
In addition to ffmpeg, you can use ImageMagick to stitch together plot() PNG files to a video file. See https://www.r-bloggers.com/animated-plots-with-r/
The animation package has wrapper functions that call on ImageMagick, ffmpeg, SWF Tools, and other 3rd party encoding utilities to create animations.
The gganimate package allows you to create animated versions of plots created with the plotting functions in the popular ggplot2 package. It also uses the animation package, so you’ll need one or more third party encoding utility installed. Code example 1. Code example 2
The tlocoh package has a function to created animations of animal movement data. Samples