Skip to content

Instantly share code, notes, and snippets.

@chasemc
Created October 7, 2021 12:54
Show Gist options
  • Save chasemc/7489860cc43aef3df8c6ca4dcd7edec0 to your computer and use it in GitHub Desktop.
Save chasemc/7489860cc43aef3df8c6ca4dcd7edec0 to your computer and use it in GitHub Desktop.
library(data.table)
library(ggplot2)
library(lubridate)
df <- fread("Shootings.csv")
df$hour = lubridate::hour(lubridate::mdy_hms(df$Date))
new_df <- df[, list(arrest = sum(Arrest), no_arrest = sum(!Arrest), total_reports = length(Arrest)), Year]
ggplot(new_df) +
geom_point(aes(x = Year,y = arrest/total_reports)) +
coord_cartesian(ylim=c(0, 0.15)) +
ylab("Arrest / Total Reports")
ggplot(new_df) +
geom_point(aes(x = Year,y = total_reports)) +
ylab("Total Reports")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment