The CDC publishes firearm mortality for each State per 100,000 persons https://www.cdc.gov/nchs/pressroom/sosmap/firearm_mortality/firearm.htm. Each State’ firearm control laws can be categorized as very strict to very lax. The purpose of this Story is to answer the question, ” Do stricter firearm control laws help reduce firearm mortality?”
For this assignment you will need to:
Access the firearm mortality data from the CDC using an available API (https://open.cdc.gov/apis.html)
Create a 5 point Likert scale categorizing gun control laws from most lax to strictest and assign each state to the most appropriate Likert bin.
Determine whether stricter gun control laws result in reduced gun violence deaths
Present your story using heat maps
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'jsonlite'
##
##
## The following object is masked from 'package:purrr':
##
## flatten
##
##
##
## Attaching package: 'plotly'
##
##
## The following object is masked from 'package:httr':
##
## config
##
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
##
## The following object is masked from 'package:stats':
##
## filter
##
##
## The following object is masked from 'package:graphics':
##
## layout
##
##
##
## Attaching package: 'rvest'
##
##
## The following object is masked from 'package:readr':
##
## guess_encoding
Data extracted from the CDC website
Filter data to obtain only the necessary columns for this analysis, I’m going to work with the last quarter of last year(2023) for this scenario
Extracted from the law center score card, data scrapped from URL table
Remove columns to keep only the columns need it for the analysis.
Convert values of Grade column into integer.
Merge both Datasets to create visualizations
First heatmap displays the gun control laws strength rating for each state with the mortality rate on it, with 1 as most lax to 5 as most strict.
## `geom_smooth()` using formula = 'y ~ x'
Based on the visualization, the answer is yes, stricter firearms laws reduce firearm mortality, states with most strict firearms laws such as California, New Jersey, and Colorado tends to have a lower gun death rate(per 100k) than other states such as Alabama, Arizona, and Georgia with the most lax gun control laws with higher gun death rate(per 100k)