Here we pull firearms death rates by year and state. The CDC provides a range of what is considered low to high death rates, which we categorize into a new variable: rate_category. We also add gun law strength using a Likert scale — 1 being a state with lax gun laws and 5 being a state with strong gun laws.
combined_data <- bind_rows(
read_csv("data-table_14.csv"),
read_csv("data-table_15.csv"),
read_csv("data-table_16.csv"),
read_csv("data-table_17.csv"),
read_csv("data-table_18.csv"),
read_csv("data-table_19.csv"),
read_csv("data-table_20.csv"),
read_csv("data-table_21.csv"),
read_csv("data-table_22.csv"),
read_csv("data-table_23.csv"),
read_csv("data-table_24.csv")
)
combined_data <- combined_data %>%
select(-URL) %>%
mutate(rate_category = case_when(
`Death Rate` >= 2.1 & `Death Rate` < 8.46 ~ "Low",
`Death Rate` >= 8.46 & `Death Rate` < 14.82 ~ "Moderate-Low",
`Death Rate` >= 14.82 & `Death Rate` < 21.18 ~ "Moderate",
`Death Rate` >= 21.18 & `Death Rate` < 27.54 ~ "Moderate-High",
`Death Rate` >= 27.54 & `Death Rate` <= 33.9 ~ "High",
))
gun_laws <- tribble(
~Location, ~law_likert,
"AL", 2, "AK", 1, "AZ", 1, "AR", 1, "CA", 5,
"CO", 4, "CT", 5, "DE", 5, "FL", 3, "GA", 1,
"HI", 5, "ID", 1, "IL", 5, "IN", 2, "IA", 2,
"KS", 1, "KY", 1, "LA", 2, "ME", 3, "MD", 5,
"MA", 5, "MI", 4, "MN", 4, "MS", 1, "MO", 1,
"MT", 1, "NE", 3, "NV", 4, "NH", 1, "NJ", 5,
"NM", 4, "NY", 5, "NC", 3, "ND", 2, "OH", 2,
"OK", 1, "OR", 4, "PA", 4, "RI", 4, "SC", 2,
"SD", 1, "TN", 2, "TX", 2, "UT", 2, "VT", 4,
"VA", 4, "WA", 5, "WV", 2, "WI", 3, "WY", 1,
"DC", 5)
final_data <- combined_data %>%
left_join(gun_laws, by = "Location")
final_data
## # A tibble: 6,732 × 6
## YEAR Location `Death Rate` Deaths rate_category law_likert
## <dbl> <chr> <dbl> <dbl> <chr> <dbl>
## 1 2024 AL 23.7 1212 Moderate-High 2
## 2 2024 AK 24.4 182 Moderate-High 1
## 3 2024 AZ 16.9 1331 Moderate 1
## 4 2024 AR 20.6 638 Moderate 1
## 5 2024 CA 7 2853 Low 5
## 6 2024 CO 15.3 961 Moderate 4
## 7 2024 CT 5.8 224 Low 5
## 8 2024 DE 11.8 123 Moderate-Low 5
## 9 2024 District of Columbia 19.7 148 Moderate NA
## 10 2024 FL 12.7 3191 Moderate-Low 3
## # ℹ 6,722 more rows
state_summary <- final_data %>%
group_by(Location, law_likert) %>%
summarise(
avg_death_rate = mean(`Death Rate`, na.rm = TRUE), # average death rates
.groups = "drop"
) %>%
mutate(rate_category = case_when(
avg_death_rate < 8.46 ~ "Low",
avg_death_rate < 14.82 ~ "Moderate-Low",
avg_death_rate < 21.18 ~ "Moderate",
avg_death_rate < 27.54 ~ "Moderate-High",
TRUE ~ "High"
))
options(tigris_use_cache = TRUE)
states_map <- tigris::states(cb = TRUE, year = 2022) %>%
mutate(Location = STUSPS)
map_data <- states_map %>%
left_join(state_summary, by = "Location")
ggplot(map_data) +
geom_sf(aes(fill = avg_death_rate), color = "white") +
scale_fill_gradient(low = "#fee5d9", high = "#a50f15") +
coord_sf(xlim = c(-125,-66), ylim = c(25,50), expand = FALSE) +
labs(
title = "Average Firearm Mortality Rate by State",
fill = "Deaths per 100k"
) +
theme_minimal()
This heat map highlights the average firearm mortality rate across the United States by color. Higher death rates appear in a darker shade of red, as seen in several Southern states, such as Louisiana, Mississippi, and Alabama. Lower death rates appear in a lighter shade of red, as seen in states such as New York and California.
ggplot(map_data) +
geom_sf(aes(fill = factor(law_likert)), color = "white") +
scale_fill_brewer(palette = "Blues") +
coord_sf(xlim = c(-125,-66), ylim = c(25,50), expand = FALSE) +
labs(
title = "Gun Law Strictness by State",
fill = "Law Strength"
) +
theme_minimal()
Our second heat map highlights gun law strictness by state. States with stronger gun laws are depicted in a darker shade of blue while states with weaker gun laws in a lighter shade of blue. States along both coasts appear to have stronger gun laws, while states in the South and Midwest hold much weaker gun restrictions. Mississippi appears to have extremely lax gun laws, but our previous map shows it has one of the higher firearms death rates.
ggplot(map_data) +
geom_sf(aes(fill = rate_category), color = "white") +
scale_fill_manual(values = c(
"Low" = "#fee5d9",
"Moderate-Low" = "#fcae91",
"Moderate" = "#fb6a4a",
"Moderate-High" = "#de2d26",
"High" = "#a50f15"
)) +
coord_sf(xlim = c(-125,-66), ylim = c(25,50), expand = FALSE) +
labs(
title = "Firearm Mortality Categories by State",
fill = "Mortality Level"
) +
theme_minimal()
Our third heat map categorizes states according to firearm mortality levels. States with weaker firearm regulations appear in higher mortality categories, while states with stronger gun laws often fall into lower mortality categories. However, there are notable exceptions. For example, New Mexico has relatively strong firearm regulations, but still falls into a higher mortality category, while Texas exhibits lower mortality levels despite having relatively weaker gun laws. These exceptions suggest that other factors beyond firearm policy may also influence firearm mortality.
Overall, firearm mortality against gun law strictness reveals a noticeable pattern. States with weaker firearm regulations tend to experience higher firearm mortality rates, while states with stronger gun laws generally exhibit lower mortality levels. Although correlation is not causation, and other factors come into play, the visual patterns suggest a meaningful association between gun law strength and firearm mortality.