8.6 Exercise
- You can choose between…
- …changing and potentially improving Figure 8.1.
- …animating some of your own data (potentially this takes longer).
- …playing around with the gapminder dataset used in the animation in Figure 8.2 below (official example of the package).
- e.g., pick another variable and/or change the animation details.
gapminder <- gapminder %>% filter(continent!="Oceania")
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
geom_point(alpha = 0.7, show.legend = FALSE) +
scale_colour_manual(values = country_colors) +
scale_size(range = c(2, 12)) +
scale_x_log10() +
facet_wrap(~continent) +
labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
transition_time(year) +
ease_aes('linear')
anim_save("animation_gapminder.gif",
animation = last_animation(),
path = "www/images/")

Figure 8.2: Animating gapminder data