• Steven Ponce
  • About
  • Data Visualizations
  • Projects
  • Email

On this page

  • Steps to Create this Graphic
    • 1. Load Packages & Setup
    • 2. Read in the Data
    • 3. Examine the Data
    • 4. Tidy Data
    • 5. Visualization Parameters
    • 6. Plot
    • 7. Save
    • 8. Session Info
    • 9. GitHub Repository
    • 10. References

Aid Worker Security: A Global Analysis of Risks and Incidents

  • Show All Code
  • Hide All Code

  • View Source

Analysis of attack patterns and their impact on humanitarian organizations worldwide

TidyTuesday
Data Visualization
R Programming
2025
Exploring the complexities of humanitarian aid worker security through data visualization. This analysis reveals critical patterns in attack incidents and risk levels across global conflict zones, demonstrating how different humanitarian organizations face varying security challenges. The visualization combines risk score analysis with incident frequency data, offering insights into the disconnect between severity and frequency of security events in different regions
Author

Steven Ponce

Published

January 7, 2025

Figure 1: This visualization examines aid worker security from 2017 to 2024. The top section features a dual bar chart comparing the risk scores and number of incidents across 10 countries. The Occupied Palestinian Territories have the highest risk score, while Afghanistan and South Sudan have the most incidents, highlighting differences in the severity versus frequency of attacks. The bottom section displays a heatmap showing attack impacts on different organization types (ICRC, INGO, NNGO, NRCS/IFRC, UN). The heatmap reveals that INGOs are most affected by shootings and kidnappings, while UN organizations experience a broader distribution of attack types. Color intensity indicates the number of aid workers impacted..

Steps to Create this Graphic

1. Load Packages & Setup

Show code
## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
pacman::p_load(
    tidyverse,      # Easily Install and Load the 'Tidyverse'
    ggtext,         # Improved Text Rendering Support for 'ggplot2'
    showtext,       # Using Fonts More Easily in R Graphs
    janitor,        # Simple Tools for Examining and Cleaning Dirty Data
    skimr,          # Compact and Flexible Summaries of Data
    scales,         # Scale Functions for Visualization
    glue,           # Interpreted String Literals
    here,           # A Simpler Way to Find Your Files
    patchwork,      # The Composer of Plots
    camcorder,      # Record Your Plot History 
    readxl          # Read Excel Files
)
})

# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))

2. Read in the Data

Show code
aid_raw <- read_excel(
  here::here("data/Aid Worker Incidents.xlsx")) |> 
    clean_names()

3. Examine the Data

Show code
glimpse(aid_raw)
skim(aid_raw)

4. Tidy Data

Show code
# data plot ---
# data for both risk score and incidents
country_analysis <- aid_raw |>
    group_by(country) |>  
    mutate(risk_score = total_killed * 3 + total_wounded * 2 + total_kidnapped) |>
    summarise(
        avg_risk = mean(risk_score),
        incidents = n(),
        total_affected = sum(total_affected),
        .groups = 'drop'
    ) |>
    arrange(desc(incidents)) |>
    slice_head(n = 10)

# Vulnerability Heatmap
vulnerability_matrix <- aid_raw |>
    select(un, ingo, icrc, nrcs_and_ifrc, nngo, means_of_attack) |>
    pivot_longer(-means_of_attack, 
                 names_to = "org_type", 
                 values_to = "count") |>
    group_by(means_of_attack, org_type) |>
    summarise(total_affected = sum(count), .groups = 'drop') |>
    mutate(
        org_type = case_when(
            org_type == "un" ~ "UN",
            org_type == "ingo" ~ "INGO",
            org_type == "icrc" ~ "ICRC",
            org_type == "nrcs_and_ifrc" ~ "NRCS/IFRC",
            org_type == "nngo" ~ "NNGO"
        ),
        means_of_attack = str_to_title(means_of_attack)
    )

5. Visualization Parameters

Show code
### |-  plot aesthetics ----
# Get base colors with custom palette
colors <- get_theme_colors(palette = c("#f7fbff", "#9ecae1", "#2171b5", "#084594"))

### |-  titles and caption ----
title_text    <- str_glue("Aid Worker Security: A Global Analysis of Risks and Incidents")
subtitle_text <- str_glue("Analysis of attack patterns and their impact on humanitarian organizations worldwide")

# Create caption
caption_text <- create_social_caption(
    tt_year = 2025,
    tt_week = 01,
    source_text = "Aid Worker Security Database via Makeover Monday"
)

### |-  fonts ----
setup_fonts()
fonts <- get_font_families()

### |-  plot theme ----

# Start with base theme
base_theme <- create_base_theme(colors)

# Add weekly-specific theme elements
weekly_theme <- extend_weekly_theme(
    base_theme,
    theme(
        # Weekly-specific modifications
        axis.line.x           = element_line(color = "#252525", linewidth = .2),
        
        panel.spacing.x       = unit(2, 'lines'),
        panel.spacing.y       = unit(1, 'lines'),
        panel.grid.major.x    = element_blank(),
        panel.grid.major.y    = element_line(color = alpha(colors[5], 0.2), linewidth = 0.2),
        panel.grid.minor      = element_blank(),
    )
)

# Set theme
theme_set(weekly_theme)

6. Plot

Show code
### |-  Plot ----
# 1. Risk Score Plot
p1 <- ggplot(country_analysis, 
             aes(x = reorder(country, avg_risk), 
                 y = avg_risk)) +
    geom_col(fill = colors$palette[4]) +
    coord_flip() +
    labs(
        title = "Risk Score by Country",
        subtitle = "Risk Score = (Deaths × 3) + (Injuries × 2) + Kidnappings",  
        x = NULL,
        y = "Risk Score"
    ) +
    theme_minimal() +
    theme(
        plot.title = element_text(face = "bold", size = rel(1)),
        plot.subtitle = element_text(size = 10, color = colors$text),
        panel.grid.minor = element_blank(),
        panel.grid.major.y = element_blank()
    )

# 2. Incidents Count Plot
p2 <- ggplot(country_analysis, 
             aes(x = reorder(country, avg_risk), 
                 y = incidents)) +
    geom_col(fill = colors$palette[2]) +
    coord_flip() +
    labs(
        title = "Number of Incidents",
        x = NULL,
        y = "Number of Incidents"
    ) +
    theme_minimal() +
    theme(
        plot.title = element_text(face = "bold", size = rel(1)),
        panel.grid.minor = element_blank(),
        panel.grid.major.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()
    )

# 3. Vulnerability Heatmap
p3 <- ggplot(vulnerability_matrix, 
                             aes(x = org_type, 
                                 y = means_of_attack, 
                                 fill = total_affected)) +
    geom_tile(color = "white", linewidth = 0.5) +
    scale_fill_gradientn(
        colors = colors$palette,
        na.value = "#f0f0f0",
        name = "Total\nAffected"
    ) +
    labs(
        title = "Attack Impact by Organization Type and Method",
        subtitle = "Total number of aid workers affected by each type of attack",
        x = "Organization Type",
        y = NULL
    ) +
    theme_minimal() +
    theme(
        plot.title = element_text(face = "bold", size = 14),
        plot.subtitle = element_text(size = 12, color = "gray30"),
        plot.caption = element_text(size = 8, color = "gray50"),
        panel.grid = element_blank(),
        axis.text.x = element_text(angle = 45, hjust = 1),
        legend.position = "right"
    )

# Final combined plot 
combined_plot <- (p1 + p2) / p3 +
    plot_layout(heights = c(1,1)) 

combined_plot <- combined_plot +
    plot_annotation(
        title    = title_text,
        subtitle = subtitle_text,
        caption  = caption_text,
        theme = theme(
            plot.title = element_text(
                family = fonts$title, 
                size   = rel(1.9), 
                face   = "bold",
                color  = colors$title,
                margin = margin(b = 10)
            ),
            plot.subtitle = element_text(
                family = fonts$text,
                lineheight = 1.1,
                size   = rel(1.1),
                color  = colors$subtitle,
                margin = margin(b = 15)
            ),
            plot.caption = element_markdown(
                family = fonts$caption,
                size   = rel(0.65),
                color  = colors$caption,
                hjust  = 0.5,
                margin = margin(t = 5)
            ),
            plot.margin = margin(10, 10, 10, 10),
        )
    )   

7. Save

Show code
### |-  plot image ----  

save_plot_patchwork (combined_plot, type = "tidytuesday", 
          year = 2025, week = 01, width = 10, height = 12)

8. Session Info

Expand for Session Info
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] readxl_1.4.3    camcorder_0.1.0 patchwork_1.3.0 here_1.0.1     
 [5] glue_1.8.0      scales_1.3.0    skimr_2.1.5     janitor_2.2.0  
 [9] showtext_0.9-7  showtextdb_3.0  sysfonts_0.8.9  ggtext_0.1.2   
[13] lubridate_1.9.3 forcats_1.0.0   stringr_1.5.1   dplyr_1.1.4    
[17] purrr_1.0.2     readr_2.1.5     tidyr_1.3.1     tibble_3.2.1   
[21] ggplot2_3.5.1   tidyverse_2.0.0

loaded via a namespace (and not attached):
 [1] gtable_0.3.6       xfun_0.49          htmlwidgets_1.6.4  tzdb_0.4.0        
 [5] yulab.utils_0.1.8  vctrs_0.6.5        tools_4.4.0        generics_0.1.3    
 [9] curl_6.0.0         gifski_1.32.0-1    fansi_1.0.6        pacman_0.5.1      
[13] pkgconfig_2.0.3    ggplotify_0.1.2    lifecycle_1.0.4    compiler_4.4.0    
[17] farver_2.1.2       munsell_0.5.1      repr_1.1.7         codetools_0.2-20  
[21] snakecase_0.11.1   htmltools_0.5.8.1  yaml_2.3.10        pillar_1.9.0      
[25] magick_2.8.5       commonmark_1.9.2   tidyselect_1.2.1   digest_0.6.37     
[29] stringi_1.8.4      labeling_0.4.3     rsvg_2.6.1         rprojroot_2.0.4   
[33] fastmap_1.2.0      grid_4.4.0         colorspace_2.1-1   cli_3.6.3         
[37] magrittr_2.0.3     base64enc_0.1-3    utf8_1.2.4         withr_3.0.2       
[41] timechange_0.3.0   rmarkdown_2.29     cellranger_1.1.0   hms_1.1.3         
[45] evaluate_1.0.1     knitr_1.49         markdown_1.13      gridGraphics_0.5-1
[49] rlang_1.1.4        gridtext_0.1.5     Rcpp_1.0.13-1      xml2_1.3.6        
[53] renv_1.0.3         svglite_2.1.3      rstudioapi_0.17.1  jsonlite_1.8.9    
[57] R6_2.5.1           fs_1.6.5           systemfonts_1.1.0 

9. GitHub Repository

Expand for GitHub Repo

The complete code for this analysis is available in tt_2025_01.qmd.

For the full repository, click here.

10. References

Expand for References
  1. Data Sources:
    • Aid Worker Security Database (AWSD): Search Incidents
    • Makeover Monday 2024 Week 46: Aid Worker Security Incidents
  2. Reports:
    • Humanitarian Outcomes. (2024). Aid Worker Security Report: Figures at a Glance 2024
Back to top
Source Code
---
title: "Aid Worker Security: A Global Analysis of Risks and Incidents"
subtitle: "Analysis of attack patterns and their impact on humanitarian organizations worldwide"
description: "Exploring the complexities of humanitarian aid worker security through data visualization. This analysis reveals critical patterns in attack incidents and risk levels across global conflict zones, demonstrating how different humanitarian organizations face varying security challenges. The visualization combines risk score analysis with incident frequency data, offering insights into the disconnect between severity and frequency of security events in different regions"
author: "Steven Ponce"
date: "2025-01-07" 
categories: ["TidyTuesday", "Data Visualization", "R Programming", "2025"]
tags: [tidytuesday, rstats, dataviz, ggplot2, patchwork, humanitarian, security, data-analysis, tidyverse, risk-analysis, aid-workers, conflict-zones, visualization, heatmap, bar-chart, dual-panel]
image: "thumbnails/tt_2025_01.png"
format:
  html:
    toc: true
    toc-depth: 5
    code-link: true
    code-fold: true
    code-tools: true
    code-summary: "Show code"
    self-contained: true
    theme: 
      light: [flatly, assets/styling/custom_styles.scss]
      dark: [darkly, assets/styling/custom_styles_dark.scss]
editor_options: 
  chunk_output_type: inline
execute: 
  freeze: true                                                  
  cache: true                                                   
  error: false
  message: false
  warning: false
  eval: true
# filters:
#   - social-share
# share:
#   permalink: "https://stevenponce.netlify.app/data_visualizations/TidyTuesday/2025/tt_2025_01.html"
#   description: "A data visualization exploring global aid worker security patterns, revealing how risk severity and incident frequency vary across regions and humanitarian organizations. #TidyTuesday 2025 Week 1"
#   twitter: true
#   linkedin: true
#   email: true
#   facebook: false
#   reddit: false
#   stumble: false
#   tumblr: false
#   mastodon: true
#   bsky: true
---

![This visualization examines aid worker security from 2017 to 2024. The top section features a dual bar chart comparing the risk scores and number of incidents across 10 countries. The Occupied Palestinian Territories have the highest risk score, while Afghanistan and South Sudan have the most incidents, highlighting differences in the severity versus frequency of attacks. The bottom section displays a heatmap showing attack impacts on different organization types (ICRC, INGO, NNGO, NRCS/IFRC, UN). The heatmap reveals that INGOs are most affected by shootings and kidnappings, while UN organizations experience a broader distribution of attack types. Color intensity indicates the number of aid workers impacted..](tt_2025_01.png){#fig-1}

### <mark> **Steps to Create this Graphic** </mark>

#### 1. Load Packages & Setup

```{r}
#| label: load
#| warning: false
#| message: false      
#| results: "hide"     

## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
pacman::p_load(
    tidyverse,      # Easily Install and Load the 'Tidyverse'
    ggtext,         # Improved Text Rendering Support for 'ggplot2'
    showtext,       # Using Fonts More Easily in R Graphs
    janitor,        # Simple Tools for Examining and Cleaning Dirty Data
    skimr,          # Compact and Flexible Summaries of Data
    scales,         # Scale Functions for Visualization
    glue,           # Interpreted String Literals
    here,           # A Simpler Way to Find Your Files
    patchwork,      # The Composer of Plots
    camcorder,      # Record Your Plot History 
    readxl          # Read Excel Files
)
})

# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```

#### 2. Read in the Data

```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false

aid_raw <- read_excel(
  here::here("data/Aid Worker Incidents.xlsx")) |> 
    clean_names()
```

#### 3. Examine the Data

```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false

glimpse(aid_raw)
skim(aid_raw)
```

#### 4. Tidy Data

```{r}
#| label: tidy
#| warning: false

# data plot ---
# data for both risk score and incidents
country_analysis <- aid_raw |>
    group_by(country) |>  
    mutate(risk_score = total_killed * 3 + total_wounded * 2 + total_kidnapped) |>
    summarise(
        avg_risk = mean(risk_score),
        incidents = n(),
        total_affected = sum(total_affected),
        .groups = 'drop'
    ) |>
    arrange(desc(incidents)) |>
    slice_head(n = 10)

# Vulnerability Heatmap
vulnerability_matrix <- aid_raw |>
    select(un, ingo, icrc, nrcs_and_ifrc, nngo, means_of_attack) |>
    pivot_longer(-means_of_attack, 
                 names_to = "org_type", 
                 values_to = "count") |>
    group_by(means_of_attack, org_type) |>
    summarise(total_affected = sum(count), .groups = 'drop') |>
    mutate(
        org_type = case_when(
            org_type == "un" ~ "UN",
            org_type == "ingo" ~ "INGO",
            org_type == "icrc" ~ "ICRC",
            org_type == "nrcs_and_ifrc" ~ "NRCS/IFRC",
            org_type == "nngo" ~ "NNGO"
        ),
        means_of_attack = str_to_title(means_of_attack)
    )
```

#### 5. Visualization Parameters

```{r}
#| label: params
#| include: true
#| warning: false

### |-  plot aesthetics ----
# Get base colors with custom palette
colors <- get_theme_colors(palette = c("#f7fbff", "#9ecae1", "#2171b5", "#084594"))

### |-  titles and caption ----
title_text    <- str_glue("Aid Worker Security: A Global Analysis of Risks and Incidents")
subtitle_text <- str_glue("Analysis of attack patterns and their impact on humanitarian organizations worldwide")

# Create caption
caption_text <- create_social_caption(
    tt_year = 2025,
    tt_week = 01,
    source_text = "Aid Worker Security Database via Makeover Monday"
)

### |-  fonts ----
setup_fonts()
fonts <- get_font_families()

### |-  plot theme ----

# Start with base theme
base_theme <- create_base_theme(colors)

# Add weekly-specific theme elements
weekly_theme <- extend_weekly_theme(
    base_theme,
    theme(
        # Weekly-specific modifications
        axis.line.x           = element_line(color = "#252525", linewidth = .2),
        
        panel.spacing.x       = unit(2, 'lines'),
        panel.spacing.y       = unit(1, 'lines'),
        panel.grid.major.x    = element_blank(),
        panel.grid.major.y    = element_line(color = alpha(colors[5], 0.2), linewidth = 0.2),
        panel.grid.minor      = element_blank(),
    )
)

# Set theme
theme_set(weekly_theme)
```

#### 6. Plot

```{r}
#| label: plot
#| warning: false

### |-  Plot ----
# 1. Risk Score Plot
p1 <- ggplot(country_analysis, 
             aes(x = reorder(country, avg_risk), 
                 y = avg_risk)) +
    geom_col(fill = colors$palette[4]) +
    coord_flip() +
    labs(
        title = "Risk Score by Country",
        subtitle = "Risk Score = (Deaths × 3) + (Injuries × 2) + Kidnappings",  
        x = NULL,
        y = "Risk Score"
    ) +
    theme_minimal() +
    theme(
        plot.title = element_text(face = "bold", size = rel(1)),
        plot.subtitle = element_text(size = 10, color = colors$text),
        panel.grid.minor = element_blank(),
        panel.grid.major.y = element_blank()
    )

# 2. Incidents Count Plot
p2 <- ggplot(country_analysis, 
             aes(x = reorder(country, avg_risk), 
                 y = incidents)) +
    geom_col(fill = colors$palette[2]) +
    coord_flip() +
    labs(
        title = "Number of Incidents",
        x = NULL,
        y = "Number of Incidents"
    ) +
    theme_minimal() +
    theme(
        plot.title = element_text(face = "bold", size = rel(1)),
        panel.grid.minor = element_blank(),
        panel.grid.major.y = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks.y = element_blank()
    )

# 3. Vulnerability Heatmap
p3 <- ggplot(vulnerability_matrix, 
                             aes(x = org_type, 
                                 y = means_of_attack, 
                                 fill = total_affected)) +
    geom_tile(color = "white", linewidth = 0.5) +
    scale_fill_gradientn(
        colors = colors$palette,
        na.value = "#f0f0f0",
        name = "Total\nAffected"
    ) +
    labs(
        title = "Attack Impact by Organization Type and Method",
        subtitle = "Total number of aid workers affected by each type of attack",
        x = "Organization Type",
        y = NULL
    ) +
    theme_minimal() +
    theme(
        plot.title = element_text(face = "bold", size = 14),
        plot.subtitle = element_text(size = 12, color = "gray30"),
        plot.caption = element_text(size = 8, color = "gray50"),
        panel.grid = element_blank(),
        axis.text.x = element_text(angle = 45, hjust = 1),
        legend.position = "right"
    )

# Final combined plot 
combined_plot <- (p1 + p2) / p3 +
    plot_layout(heights = c(1,1)) 

combined_plot <- combined_plot +
    plot_annotation(
        title    = title_text,
        subtitle = subtitle_text,
        caption  = caption_text,
        theme = theme(
            plot.title = element_text(
                family = fonts$title, 
                size   = rel(1.9), 
                face   = "bold",
                color  = colors$title,
                margin = margin(b = 10)
            ),
            plot.subtitle = element_text(
                family = fonts$text,
                lineheight = 1.1,
                size   = rel(1.1),
                color  = colors$subtitle,
                margin = margin(b = 15)
            ),
            plot.caption = element_markdown(
                family = fonts$caption,
                size   = rel(0.65),
                color  = colors$caption,
                hjust  = 0.5,
                margin = margin(t = 5)
            ),
            plot.margin = margin(10, 10, 10, 10),
        )
    )   
```

#### 7. Save

```{r}
#| label: save
#| warning: false

### |-  plot image ----  

save_plot_patchwork (combined_plot, type = "tidytuesday", 
          year = 2025, week = 01, width = 10, height = 12)
```

#### 8. Session Info

::: {.callout-tip collapse="true"}
##### Expand for Session Info

```{r, echo = FALSE}
#| eval: true
#| warning: false

sessionInfo()
```
:::

#### 9. GitHub Repository

::: {.callout-tip collapse="true"}
##### Expand for GitHub Repo

The complete code for this analysis is available in [`tt_2025_01.qmd`](https://github.com/poncest/personal-website/blob/master/data_visualizations/TidyTuesday/2025/tt_2025_01.qmd).

For the full repository, [click here](https://github.com/poncest/personal-website/).
:::


#### 10. References
::: {.callout-tip collapse="true"}
##### Expand for References

1. Data Sources:
   - Aid Worker Security Database (AWSD): [Search Incidents](https://www.aidworkersecurity.org/incidents/search)
   - Makeover Monday 2024 Week 46: [Aid Worker Security Incidents](https://data.world/makeovermonday/2024w46-aid-worker-security-incidents)

2. Reports:
   - Humanitarian Outcomes. (2024). [Aid Worker Security Report: Figures at a Glance 2024](https://humanitarianoutcomes.org/sites/default/files/publications/figures_at_a_glance_2024.pdf)
   
 
:::

© 2024 Steven Ponce

Source Issues