Last active
February 20, 2022 19:06
-
-
Save dickoa/6ba82330ec232d244013f9bfa39054c1 to your computer and use it in GitHub Desktop.
Mali violence map ACLED
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(sf) | |
library(rgeoboundaries) ## remotes::install_github("wmgeolabs/rgeoboundaries") | |
library(racled) ## remotes::install_gitlab("dickoa/racled") | |
library(cowplot) | |
### Get Mali country boundaries | |
mli_adm0 <- gb_adm0("mali") | |
### Get Mali ACLED data | |
mli_acled <- read_acled("mali") | |
glimpse(mli_acled) ## check the data | |
## Create spatial objects, lumping event_type | |
mli_acled_pts <- mli_acled |> | |
filter(year >= 2013, | |
year <= 2021, | |
fatalities >= 1) |> | |
mutate(event_type2 = fct_lump(event_type, | |
n = 3, | |
other_level = "Other events")) |> | |
drop_na(longitude, latitude) |> | |
st_as_sf(coords = c("longitude", "latitude"), | |
crs = 4326) | |
## Color palette | |
pal <- c("Battles" = "#BF1154", | |
"Explosions/Remote violence" = "#DA7C5D", | |
"Violence against civilians" = "#F2D16D", | |
"Other events" = "#525A61") | |
### The chart | |
ggplot() + | |
geom_sf(data = mli_adm0) + | |
geom_sf(data = mli_acled_pts, | |
aes(size = fatalities, | |
fill = event_type2), | |
shape = 21, | |
stroke = 0.1, | |
alpha = 0.7) + | |
labs(title = "Violence in Mali since 2013", | |
subtitle = "Events resulting in more than one fatality", | |
caption = "Source: ACLED") + | |
scale_fill_manual("", values = pal, | |
guide = guide_legend(override.aes = list(size = 3))) + | |
scale_size(name = "Dead", | |
breaks = c(10, 157), | |
range = c(1, 4), | |
guide = guide_legend(title.position = "right")) + | |
facet_wrap(vars(fct_rev(as.factor(year)))) + | |
theme_map() + | |
theme(legend.position = "top", | |
legend.direction = "horizontal", | |
plot.caption = element_text(hjust = 0, vjust = 1), | |
plot.caption.position = "plot") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @dickoa,
thank you