1. Introduction

In this assignment, we will navigate Fatal Encounters data created by D. Brian Burghart, the Project Specialist of University of Southern California and the President of FatalEncounters.org, which contains records of people who’ve been killed through interactions with law enforcement in 50 states and D.C. since Jan. 1, 2000.

Loading required library

library(tidycensus)
library(tidyverse)
library(tmap)
library(sf)
library(jsonlite)
library(lubridate)
library(dplyr)
library(ggplot2)
library(ggpubr)
library(broom)

Loading data

dataset <- read.csv("E:/Georgia_Tech_MCRP/2024_FALL/CP8883_Urban_Analytics/Assignment/Assignment_5/Fatal_Dataset.csv")

Data Inspection

dataset
colnames(dataset)
colSums(is.na(dataset))

2. Major Findings

From the dataset, we can identify that fatal encounters in the U.S. are constantly increasing on a yearly basis, with California, Texas, Florida, Georgia, and Illinois being the top five states with the highest fatal encounters over the last 20 years. If we take a closer look at the fatal encounters in Georgia, a state with the fourth largest number of fatal encounters in the U.S. over the past two decades, we see that the majority of those killed during encounters with law enforcement officers were male, with most victims falling within the age group of 10 to 39, where a significant number were Black. At all age groups, Asians/Pacific Islanders and Hispanics show very minimal numbers of fatal encounters. Lastly, when we examine the locations of fatal incidents in Fulton, DeKalb, and Gwinnett Counties—the three largest counties in the Atlanta Metro area—we observe a distinct geographical disparity in racial demographics. The predominant number of African-American fatal encounters is located in Southern Fulton and DeKalb Counties, while fatal encounters involving White individuals are more concentrated in North Fulton and Gwinnett Counties. Fatal encounters involving Asians are largely concentrated within Gwinnett County. The following graphs and maps illustrate the fatal encounter dynamics in the US as well as the state of Georgia in a detailed manner: 3 #### [Graph 1] Yearly trend: Fatal encounters in US

# Create Date and Year column
dataset$Date <- as.Date(dataset$Date.of.injury.resulting.in.death..month.day.year., format = "%m/%d/%Y")
dataset$Year <- year(dataset$Date)

# Plot the data
ggplot(data = dataset) + 
  geom_bar(mapping = aes(x = Year), fill = "red") + 
  geom_text(stat = 'count', aes(x = Year, label = ..count..), vjust = -.5, size = 2.5) 
## Warning: The dot-dot notation (`..count..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(count)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

  labs(title = "[Graph 1] Yearly trend: Fatal encounters in US") +
  theme_minimal()
## NULL

[Graph 2] Fatal encounters by State

# Fatal encounters by state
state_counts <- dataset %>%
  group_by(State) %>%
  summarise(Fatalities = n()) %>%
  arrange(desc(Fatalities))

# Top 20 States
top_20_states <- state_counts %>% top_n(20, Fatalities)

# Color-coding: Top 5 States = pink, other 15 states = blue
top_20_states <- top_20_states %>%
  mutate(Color = ifelse(rank(-Fatalities) <= 5, "pink", "blue"))  

# Plot the data
ggplot(data = top_20_states, aes(x = reorder(State, -Fatalities), y = Fatalities, fill = Color)) + 
  geom_bar(stat = "identity") + 
  geom_text(aes(label = Fatalities), vjust = -.5, size = 2.5) + 
  labs(title = "[Graph 2] Fatal Encounters by State (Top 20)",
       x = "Top 20 States",
       y = "Number of Fatalities") + 
  scale_fill_identity() +  
  theme_minimal()

#### [Graph 3] Yearly trend: Fatal encounters in Georgia

# Filter data for Georgia
dataset_GA <- dataset %>% filter(State == "GA")

# Create Date and Year columns
dataset_GA$Date <- as.Date(dataset_GA$Date.of.injury.resulting.in.death..month.day.year., format = "%m/%d/%Y")
dataset_GA$Year <- year(dataset_GA$Date)

# Summarize data by year and gender
summary_dataset_GA <- dataset_GA %>%
  group_by(Year, Gender) %>%
  summarise(Count = n(), .groups = "drop")

# Plot the data
ggplot(summary_dataset_GA, aes(x = Year, y = Count, fill = Gender)) +
  geom_bar(stat = "identity") +  
  labs(title = "Graph 3: Yearly trend: Fatal encounters in Georgia",
       x = "Year",
       y = "Number of Fatal Encounters",
       fill = "Gender") +
  theme_minimal()

#### [Graph 4] Fatal Encounters in Georgia by Race, Age in Georgia

# Summarize data by Age groups (10-year intervals), Race
dataset_GA_age_race <- dataset_GA %>%
  filter(!is.na(Age)) %>%
  filter(Age > 0) %>%
  filter(!is.na(Race)) %>%
  mutate(
    Age = as.numeric(Age),  
    Race = recode(Race,
                  `African-American/Black African-American/Black Not imputed` = "African-American/Black",
                  `European-American/European-American/White` = "White",
                  `European-American/White` = "White"),
    Age_Group = cut(Age, 
                    breaks = seq(0, max(Age, na.rm = TRUE) + 10, by = 10),  
                    right = FALSE, 
                    labels = paste(seq(0, max(Age, na.rm = TRUE), by = 10), 
                                   seq(9, max(Age, na.rm = TRUE) + 9, by = 10), sep = "-"))
  ) %>%
  group_by(Age_Group, Race) %>%
  summarise(Count = n(), .groups = "drop")

# Create the plot
ggplot(dataset_GA_age_race, aes(x = Age_Group, y = Count, color = Race)) +
  geom_point(aes(size = Count), alpha = 0.7) +
  labs(
    title = "[Graph 4] Fatal Encounters in Georgia by Race, Age",
    x = "Age Group",
    y = "Number of Fatal Encounters",
    color = "Race"
  ) +
  scale_size(range = c(1, 5), guide = "none") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

#### [Map 1] Locations of Fatal Encounter Incidents in Fulton, Dekalb, and Gwinnett Counties, Georgia.

# County geometries: Fulton, DeKalb, and Gwinnett counties
counties <- tigris::counties("GA", class = "sf") %>%
  filter(NAME %in% c("Fulton", "DeKalb", "Gwinnett")) %>% 
  st_transform(4326)
## Retrieving data for the year 2021
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |                                                                      |   1%
  |                                                                            
  |=                                                                     |   1%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |==                                                                    |   2%
  |                                                                            
  |==                                                                    |   3%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |===                                                                   |   5%
  |                                                                            
  |====                                                                  |   5%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |=====                                                                 |   6%
  |                                                                            
  |=====                                                                 |   7%
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |======                                                                |   9%
  |                                                                            
  |=======                                                               |   9%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |=======                                                               |  11%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |=========                                                             |  14%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |==========                                                            |  15%
  |                                                                            
  |===========                                                           |  15%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |============                                                          |  16%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |============                                                          |  18%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |=============                                                         |  19%
  |                                                                            
  |==============                                                        |  19%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |==============                                                        |  21%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |================                                                      |  23%
  |                                                                            
  |================                                                      |  24%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=================                                                     |  25%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |===================                                                   |  27%
  |                                                                            
  |===================                                                   |  28%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=====================                                                 |  29%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |=====================                                                 |  31%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |=======================                                               |  32%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |========================                                              |  35%
  |                                                                            
  |=========================                                             |  35%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |==========================                                            |  38%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |===========================                                           |  39%
  |                                                                            
  |============================                                          |  39%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |============================                                          |  41%
  |                                                                            
  |=============================                                         |  41%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |==============================                                        |  42%
  |                                                                            
  |==============================                                        |  43%
  |                                                                            
  |==============================                                        |  44%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===============================                                       |  45%
  |                                                                            
  |================================                                      |  45%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |=================================                                     |  46%
  |                                                                            
  |=================================                                     |  47%
  |                                                                            
  |=================================                                     |  48%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |===================================                                   |  49%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |====================================                                  |  51%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |=====================================                                 |  52%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |=====================================                                 |  54%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |======================================                                |  55%
  |                                                                            
  |=======================================                               |  55%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |========================================                              |  56%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |========================================                              |  58%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |=========================================                             |  59%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |==========================================                            |  61%
  |                                                                            
  |===========================================                           |  61%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |============================================                          |  63%
  |                                                                            
  |============================================                          |  64%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |=============================================                         |  65%
  |                                                                            
  |==============================================                        |  65%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |===============================================                       |  66%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |===============================================                       |  68%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |================================================                      |  69%
  |                                                                            
  |=================================================                     |  69%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |=================================================                     |  71%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |===================================================                   |  72%
  |                                                                            
  |===================================================                   |  73%
  |                                                                            
  |===================================================                   |  74%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |=====================================================                 |  75%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |======================================================                |  76%
  |                                                                            
  |======================================================                |  77%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |=======================================================               |  79%
  |                                                                            
  |========================================================              |  79%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |========================================================              |  81%
  |                                                                            
  |=========================================================             |  81%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |==========================================================            |  82%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |==========================================================            |  84%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |============================================================          |  85%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |=============================================================         |  86%
  |                                                                            
  |=============================================================         |  87%
  |                                                                            
  |=============================================================         |  88%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |==============================================================        |  89%
  |                                                                            
  |===============================================================       |  89%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |===============================================================       |  91%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |=================================================================     |  92%
  |                                                                            
  |=================================================================     |  93%
  |                                                                            
  |=================================================================     |  94%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |==================================================================    |  95%
  |                                                                            
  |===================================================================   |  95%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |====================================================================  |  97%
  |                                                                            
  |====================================================================  |  98%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |===================================================================== |  99%
  |                                                                            
  |======================================================================|  99%
  |                                                                            
  |======================================================================| 100%
# Convert Dataset to spatial object and re-categorize Race
dataset_GA_sf <- dataset_GA %>% 
  st_as_sf(coords = c("Longitude", "Latitude"), crs = 4326) %>%
  mutate(Race = recode(Race,
                       `African-American/Black African-American/Black Not imputed` = "African-American/Black",
                       `European-American/European-American/White` = "White",
                       `European-American/White` = "White"))  

# Keep only points that are within the county borders
dataset_GA_sf <- st_intersection(dataset_GA_sf, counties)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
# Create a ggplot object
ggplot() +
  geom_sf(data = counties, fill = NA, color = "lightgray") +  
  geom_sf(data = dataset_GA_sf,  
          aes(color = Race), 
          alpha = 0.6, 
          size = 1.2) +  
  labs(title = "[Map 1] Locations of Fatal Encounter Incidents in Fulton, Dekalb, and Gwinnett Counties, Georgia",
       color = "Race") +
  coord_sf(xlim = c(-84.9, -83.7), ylim = c(33.5, 34.2)) +  
  theme_minimal() +
  theme(panel.grid = element_blank(),  
        axis.text = element_blank(),  
        axis.ticks = element_blank())  

#### [Map 2] Fatal Encounter Incident Locations in Fulton, Dekalb, and Gwinnett Counties, Georgia (race unspecified cases dropped)

# Keep only points that are within the county borders
dataset_GA_sf <- st_intersection(dataset_GA_sf, counties)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
# Drop entries with "Race unspecified"
dataset_GA_drop_sf <- dataset_GA_sf %>%
  filter(Race != "Race unspecified")  # Exclude rows where Race is "Race unspecified"

# Create a ggplot object
ggplot() +
  geom_sf(data = counties, fill = NA, color = "lightgray") +  
  geom_sf(data = dataset_GA_drop_sf,  
          aes(color = Race), 
          alpha = 0.6, 
          size = 1.2) +  
  labs(title = "[Map 2] Fatal Encounter Incident Locations in Fulton, Dekalb, and Gwinnett Counties, Georgia (race unspecified cases dropped)",
       color = "Race") +
  coord_sf(xlim = c(-84.9, -83.7), ylim = c(33.5, 34.2)) + 
  theme_minimal() +
  theme(panel.grid = element_blank(),  
        axis.text = element_blank(),  
        axis.ticks = element_blank())  

```