::: {.cell hash='08_Maps_cache/revealjs/africa-transform_b1acfecdc792b93f178683a0fd6d7d68'}

```{.r .cell-code}
library(units)

africa %>% 
  filter(pop_year == 2019) %>% 
  mutate(
    pop_density = 
      as.integer(pop_est) / 
      set_units(
        st_area(geometry), "km^2"
        ),
    pop_dens_rank = 
      rank(drop_units(pop_density))
  ) %>% 
  ggplot() +
  geom_sf(aes(fill = pop_dens_rank)) +
  scale_fill_viridis_c()
```
:::