change_africa = gapminder |>
# only Africa
filter(continent == "Africa") |>
# select down to the columns we need
select(country, year, lifeExp) |>
# keep first and last year only
filter(year == min(year) | year == max(year)) |>
# pivot wider so years on columns
pivot_wider(id_cols = country, names_from = year, values_from = lifeExp) |>
# change from 52 to 07
mutate(difference = `2007` - `1952`) |>
arrange(desc(difference))