Death penalty

Day 3 of 30DayMapChallenge. Choropleth
R
spatial
datavisualization
30DayMapChallenge
Author

Michaël

Published

2024-11-03

Modified

2024-11-22

Death Valley Winter

Death Valley Winter – CC-BY by street.light

Day 3 of 30DayMapChallenge: « Polygons » (previously).

A classic world choropleth map. We’ll use the Comparative Death Penalty Database (Anckar and Denk 2024) available on https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/LI3WYK and the basemap from {rnaturalearth} to map countries by death penalty status.

library(dplyr)
library(tibble)
library(readr)
library(glue)
library(readxl)
library(janitor)
library(ggplot2)
library(scales)
library(ggspatial)
library(sf)
library(rnaturalearth)
library(countrycode)

Data

The CDPD doesn’t use ISO A3 country codes, so we need to translate them from the Correlates of War codes with {countrycode}. Three countries need manual adjustments.

codes <- tribble(
  ~deathpenalty, ~lib_deathpenalty, ~color,
  0, "Abolished", "lightskyblue",
  1, "Abolished for ordinary crimes only", "khaki1",
  2, "Abolished for ordinary crimes only, but used during the last 10 years.", "gold1",
  3, "Abolished in practice", "indianred1",
  4, "Retained", "indianred4")

if (!file.exists("cdpd.rds")) {
  download.file("https://dataverse.harvard.edu/api/access/datafile/10251764", 
                "cdpd.xlsx")
  
  cdpd <- read_xlsx("cdpd.xlsx") |> 
    clean_names() |> 
    filter(year == 2022) |> 
    mutate(iso = countrycode(cowcode, "cown", "iso3c",
                             custom_match = c("342" = "SRB",
                                              "348" = "MNE",
                                              "818" = "VNM"))) |> 
    left_join(codes, join_by(deathpenalty)) |> 
    select(country, iso, lib_deathpenalty) |> 
    write_rds("cdpd.rds")
} else {
  cdpd <- read_rds("cdpd.rds")
}

abolished <- nrow(filter(cdpd, lib_deathpenalty == "Abolished")) / nrow(cdpd)

Map data

The easy to use dataset from Natural Earth.

country_map <- ne_countries(scale = 110, returnclass = "sf") |> 
  select(sovereignt, sov_a3, admin, adm0_a3)

Map

pal_dp <- codes |> 
  select(lib_deathpenalty, color) |> 
  deframe()

cdpd_map <- country_map |> 
  left_join(cdpd, join_by(adm0_a3 == iso)) 

cdpd_map |> 
  ggplot() +
  geom_sf(aes(fill = lib_deathpenalty)) +
  scale_fill_manual(values = pal_dp, na.value = "grey") +
  coord_sf(crs = "+proj=eqearth") +
  labs(title = glue("Death penalty is still retained in {percent(1 - abolished)} of the countries"),
       subtitle = "2022",
       fill = "Death penalty\nstatus",
       caption = glue("data: Comparative Death Penalty Database
                       map data: Natural Earth
                       r.iresmi.net - {Sys.Date()}")) +
  theme_void() +
  theme(plot.background = element_rect(color = NA, fill = "white"),
        legend.position = "bottom",
        legend.text = element_text(size = 8),
        plot.caption = element_text(size = 5,
                                    color = "darkgrey"))
A map of World death penalty status : death penalty is still retained in 44% of the countries
Figure 1: World death penalty status

References

Anckar, Carsten, and Thomas Denk. 2024. Comparative Death Penalty Database.” Harvard Dataverse. https://doi.org/10.7910/DVN/LI3WYK.