Quick animations with R
11/05/20

To quickly create gifs with R, we can create a series of images and call ffmpeg to stich them together.

# animations.R
for (i in 0:720) {
    jpeg(file=sprintf("%03d.jpg", i), width=1080, height=720) 
    persp(x, y, z, theta=i/2, phi=30)
    dev.off()
}
$ ffmpeg -f image2 -framerate 30 -i ./%3d.jpg out.gif
🡨 Prev
Index
Next 🡪