<- read.csv("https://ourworldindata.org/grapher/death-rate-in-armed-conflicts.csv?v=1&csvType=full&useColumnShortNames=true") df
%>%filter(Entity=="Spain") df
<- df %>%
death_rate filter(Year>=2018,
>0) %>% # 2018 - 2023
death_rate__conflict_type_allgroup_by(Entity,Code) %>%
reframe(Deaths = round(mean(death_rate__conflict_type_all),2))
death_rate
::profile_missing(death_rate) DataExplorer
%>%filter(Entity=="Spain") death_rate
library(rnaturalearth)
<- ne_countries(scale = "medium", returnclass = "sf") %>%
world filter(!name=="Antarctica")
<- left_join(world, death_rate, by = c("iso_a3" = "Code")) death_rate_sf
<- c("The best estimate of the number of deaths of combatants and civilians due to fighting in interstate, intrastate, extrasystemic, non-state conflicts, and one-sided violence that were ongoing that year, per 100,000 people. - Our World in Data") text
<- ggplot(data = world) +
map geom_sf(fill=NA) +
geom_sf(data = death_rate_sf,
aes(fill=Deaths)) +
labs(title = "Armed Conflicts (2018-2023)",
caption = "Data Source: Uppsala Conflict Data Program (2024)\nNatural Earth (2022), Population based on various sources (2024)\nwith major processing by Our World in Data\n#30DayMapChallenge Day21 | @fgazzelloni",
fill = "Death Rate\n(Avg-values)") +
::theme_map() +
ggthemestheme(text = element_text(family = "mono", color = "grey20", face="bold"),
legend.position = "top",
legend.background = element_rect(fill="transparent"),
plot.title = element_text(size=20),
plot.caption = element_text(size=9))
map
+
map scale_fill_continuous(low = "lightblue", high = "darkred") +
::geom_textbox(
ggtextx = -135, y = -45,
width = 0.3, height = 0.5,
label = text,
size = 3,
family = "mono",
color = "darkred",
fill = "transparent",
box.color = "transparent"
)
save it as png
ggsave("day21_conflicts.png",
bg="grey80",
width = 12, height = 6,
units = "in", dpi = 300)