Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The objective of the visualization is to compare both Republican and Democratic Presidential Terms and their respective attitudes to gun control by referencing the number of NICS firearm background checks carried out by the FBI during each of those presidential terms.
The target audience is the voting American public.
The visualisation chosen had the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
# Import the required libraries
library(ggplot2)
library(lubridate)
library(stringr)
# Read in the NICS Firearm Background Checks data
nics_df <- read.csv('nics.csv', header = TRUE)
# Create a vector of presidential terms
terms <- c('Bush\n(Term 1)', 'Bush\n(Term 2)', 'Obama\n(Term 1)', 'Obama\n(Term 2)', 'Trump\n(Term 1)')
# Create a vector of presidential party affiliations
parties <- c('Republican', 'Republican', 'Democratic', 'Democratic', 'Republican')
# Subset the dataframe to the required columns
nics_df_sub <- nics_df[c('month', 'totals')]
# Convert the month column from a factor to a date type
nics_df_sub$month <- str_c(nics_df_sub$month, '-01')
nics_df_sub$month <- ymd(nics_df_sub$month)
# Find the median firearm background checks for each presidential term:
# Bush - Term 1
bt1 <- as.integer(median(nics_df_sub[nics_df_sub$month >= "2001-02-01" & nics_df_sub$month < "2005-02-01", "totals"], na.rm = TRUE))
# Bush - Term 2
bt2 <- as.integer(median(nics_df_sub[nics_df_sub$month >= "2005-02-01" & nics_df_sub$month < "2009-02-01", "totals"], na.rm = TRUE))
# Obama - Term 1
ot1 <- as.integer(median(nics_df_sub[nics_df_sub$month >= "2009-02-01" & nics_df_sub$month < "2013-02-01", "totals"], na.rm = TRUE))
# Obama - Term 2
ot2 <- as.integer(median(nics_df_sub[nics_df_sub$month >= "2013-02-01" & nics_df_sub$month < "2017-02-01", "totals"], na.rm = TRUE))
# Trump - Term 1
tt1 <- as.integer(median(nics_df_sub[nics_df_sub$month >= "2017-02-01" & nics_df_sub$month < "2021-02-01", "totals"], na.rm = TRUE))
# Create a vector of median firearm background checks for each presidential term
checks <- c(bt1, bt2, ot1, ot2, tt1)
# Create final dataframe required for the visualisation
df <- data.frame(term = terms, check = checks)
# Create the plot
p1 <- ggplot(df, aes(x = term, y = check, fill = parties)) + geom_bar(stat = "identity", width = 0.5) + scale_fill_manual("US Political Parties", values = c("Republican" = "tomato3", "Democratic" = "royalblue4")) + labs(title = "Presidential Terms v FBI Firearm Background Checks", caption = "\nSource: NICS Firearm Background Checks by month. (2020). \n https//www.kaggle.com/pedropereira94/nics-firearm-background-checks", y = "Median Monthly Background Checks", x = "Presidential Term") + theme_minimal() + theme(axis.title.x = element_text(vjust = -2), axis.title.y = element_text(margin = margin(t = 0, r = 20, b = 0, l = 0)))
Data Reference
NICS Firearm Background Checks by month. (2020). NICS Firearm Background checks. Monthly data collected by the FBI on firearm background checks. Retrieved August 23, 2020, from Kaggle.com website: https//www.kaggle.com/pedropereira94/nics-firearm-background-checks
Coleman, D. (2020). Presidential Inauguration Dates, Washington to Trump. Retrieved September 4, 2020, from History in Pieces Website: https://historyinpieces.com/research/presidential-inauguration-dates
The following plot fixes the main issues in the original.