df1 <- data.frame(
country = c('Denmark', 'Sweden', 'Norway'),
population = c(5e6, 10e6, 3.5e6)
)
df2 <- data.frame(
country = c('Denmark', 'Sweden', 'Norway', 'Finland'),
population = c(6e6, 10.5e6, 4e6, 3e6)
)
df3 <- data.frame(
country = c('Denmark', 'Norway'),
population = c(10e6, 6e6)
)
to_zero <- function(x) {
x$population <- 0
x
}
gen <- gen_keyframe(df1, 10) %>%
add_keyframe(df2, 'cubic-in-out', 35, id = country, enter = to_zero) %>%
add_pause(10) %>%
add_keyframe(df3, 'cubic-in-out', 35, id = country, enter = to_zero,
exit = to_zero) %>%
add_pause(10)
get_frame(gen, 0.25)
Run the code above in your browser using DataLab