Load packages

library(gganimate)
library(ggplot2)
library(readr)

Read the Gapminder data

gapminder <- read_tsv("gapminderDataFiveYear.tsv")

Plot the Gapminder data

gappminder_plot <- ggplot(gapminder) +
    aes(x = lifeExp, y = gdpPercap, colour = continent,
            size = pop, frame = year) +
    geom_point(alpha = 0.4) +
    scale_y_log10()
gappminder_plot

Animate the Gapminder data

gg_animate(gappminder_plot, filename = "gapminder.gif")

Animated Gapminder figure