This is an R Markdown for the Fatal Encounters assignment for Intro to Urban Analytics.
Story: Several sources state that crime has decreased over the past two decades in major NJ cities. Does the reduction in crime result in lower fatalities when encountering law enforcement? To tackle this question we will look at five different NJ cities and compare fatal encounters with police from two different decades 2000-2009 and 2010-2019.
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.8 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.0 ✔ stringr 1.4.0
## ✔ readr 2.1.2 ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(tidycensus)
library(osmdata)
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(sfnetworks)
library(units)
## udunits database from C:/Program Files/R/R-4.2.1/library/units/share/udunits/udunits2.xml
library(sf)
## Linking to GEOS 3.9.1, GDAL 3.4.3, PROJ 7.2.1; sf_use_s2() is TRUE
library(tidygraph)
##
## Attaching package: 'tidygraph'
##
## The following object is masked from 'package:stats':
##
## filter
library(tmap)
library(dotenv)
library(viridis)
## Loading required package: viridisLite
library(dplyr)
library(ggplot2)
library(units)
library(leaflet)
library(leafsync)
library(dbscan)
library(tigris)
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
library(plotly)
##
## Attaching package: 'plotly'
##
## 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
library(here)
## here() starts at C:/Users/sbaghel3/OneDrive - Georgia Institute of Technology/Desktop/assignment5
library(patchwork)
library(rgdal)
## Loading required package: sp
## Please note that rgdal will be retired by the end of 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
##
## rgdal: version: 1.5-32, (SVN revision 1176)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.4.3, released 2022/04/22
## Path to GDAL shared files: C:/Program Files/R/R-4.2.1/library/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
## Path to PROJ shared files: C:/Program Files/R/R-4.2.1/library/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.5-0
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
library(mapview)
library(tidyr)
library(lubridate)
##
## Attaching package: 'lubridate'
##
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
crimeData <-
read.csv("crimeData.csv")
#str(crimeData)
crimeData$Latitude <- as.numeric(crimeData$Latitude)
## Warning: NAs introduced by coercion
crimeData$Longitude <- as.numeric(crimeData$Longitude)
crimeData <- crimeData %>%
filter(!is.na(Latitude))
crimeData <- crimeData %>%
filter(!is.na(Longitude))
The maps below represent fatal encounters with police. The maps show unique clusters of police fatal encounters by race, and force level. It seems like the race of several individuals involved in fatal encounters in the 2000-2009 decade were not being documented. Some interesting trends emerge when looking at the barchart counts in the next section!
*Order of Maps Newark Race (2000-2009) (2010-2019) Trenton Race (2000-2009) (2010-2019) Camden Race (2000-2009) (2010-2019) Paterson Race (2000-2009) (2010-2019) Atlantic City Race (2000-2009) (2010-2019) Newark ForceLevel (2000-2009) (2010-2019) Trenton ForceLevel (2000-2009) (2010-2019) Camden ForceLevel (2000-2009) (2010-2019) Paterson ForceLevel (2000-2009) (2010-2019) Atlantic City ForceLevel (2000-2009) (2010-2019) Newark Age (2000-2009) (2010-2019) Trenton Age (2000-2009) (2010-2019) Camden Age (2000-2009) (2010-2019) Paterson Age (2000-2009) (2010-2019) Atlantic City Age (2000-2009) (2010-2019) Newark Gender (2000-2009) (2010-2019) Trenton Gender (2000-2009) (2010-2019) Camden Gender (2000-2009) (2010-2019) Paterson Gender (2000-2009) (2010-2019) Atlantic City Gender (2000-2009) (2010-2019)
plot_Locations <- st_as_sf(crimeData, coords = c("Longitude", "Latitude"), crs= 4326)
plot_LocationsNewark20002009 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Newark") %>% filter(grepl('2000|2001|2002|2003|2004|2005|2006|2007|2008|2009',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsNewark20102019 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Newark") %>% filter(grepl('2010|2011|2012|2013|2014|2015|2016|2017|2018|2019',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsTrenton20002009 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Trenton") %>% filter(grepl('2000|2001|2002|2003|2004|2005|2006|2007|2008|2009',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsTrenton20102019 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Trenton") %>% filter(grepl('2010|2011|2012|2013|2014|2015|2016|2017|2018|2019',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsCamden20002009 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Camden") %>% filter(grepl('2000|2001|2002|2003|2004|2005|2006|2007|2008|2009',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsCamden20102019 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Camden") %>% filter(grepl('2010|2011|2012|2013|2014|2015|2016|2017|2018|2019',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsPaterson20002009 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Paterson") %>% filter(grepl('2000|2001|2002|2003|2004|2005|2006|2007|2008|2009',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsPaterson20102019 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Paterson") %>% filter(grepl('2010|2011|2012|2013|2014|2015|2016|2017|2018|2019',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsAtlanticCity20002009 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Atlantic City") %>% filter(grepl('2000|2001|2002|2003|2004|2005|2006|2007|2008|2009',FatalityDate))#(FatalityDate > '2010-01-01')
plot_LocationsAtlanticCity20102019 = plot_Locations %>% filter(State == "NJ") %>% filter(City == "Atlantic City") %>% filter(grepl('2010|2011|2012|2013|2014|2015|2016|2017|2018|2019',FatalityDate))#(FatalityDate > '2010-01-01')
tmap_mode("view")
## tmap mode set to interactive viewing
newark2000 <- tm_shape(plot_LocationsNewark20002009) + tm_dots("Race")
newark2010 <- tm_shape(plot_LocationsNewark20102019) + tm_dots("Race")
tmap_arrange(newark2000,newark2010)
trenton2000 <- tm_shape(plot_LocationsTrenton20002009) + tm_dots("Race")
trenton2010 <- tm_shape(plot_LocationsTrenton20102019) + tm_dots("Race")
tmap_arrange(trenton2000,trenton2010)
camden2000 <- tm_shape(plot_LocationsCamden20002009) + tm_dots("Race")
camden2010 <- tm_shape(plot_LocationsCamden20102019) + tm_dots("Race")
tmap_arrange(camden2000,camden2010)
paterson2000 <- tm_shape(plot_LocationsPaterson20002009) + tm_dots("Race")
paterson2010 <- tm_shape(plot_LocationsPaterson20102019) + tm_dots("Race")
tmap_arrange(paterson2000,paterson2010)
atlanticCity2000 <- tm_shape(plot_LocationsAtlanticCity20002009) + tm_dots("Race")
atlanticCity2010 <- tm_shape(plot_LocationsAtlanticCity20102019) + tm_dots("Race")
tmap_arrange(atlanticCity2000,atlanticCity2010)
newark2000fLevel <- tm_shape(plot_LocationsNewark20002009) + tm_dots("ForceLevel")
newark2010fLevel <- tm_shape(plot_LocationsNewark20102019) + tm_dots("ForceLevel")
tmap_arrange(newark2000fLevel,newark2010fLevel)
trenton2000fLevel <- tm_shape(plot_LocationsTrenton20002009) + tm_dots("ForceLevel")
trenton2010fLevel <- tm_shape(plot_LocationsTrenton20102019) + tm_dots("ForceLevel")
tmap_arrange(trenton2000fLevel,trenton2010fLevel)
camden2000fLevel <- tm_shape(plot_LocationsCamden20002009) + tm_dots("ForceLevel")
camden2010fLevel <- tm_shape(plot_LocationsCamden20102019) + tm_dots("ForceLevel")
tmap_arrange(camden2000fLevel,camden2010fLevel)
paterson2000fLevel <- tm_shape(plot_LocationsPaterson20002009) + tm_dots("ForceLevel")
paterson2010fLevel <- tm_shape(plot_LocationsPaterson20102019) + tm_dots("ForceLevel")
tmap_arrange(paterson2000fLevel,paterson2010fLevel)
atlanticCity2000fLevel <- tm_shape(plot_LocationsAtlanticCity20002009) + tm_dots("ForceLevel")
atlanticCity2010fLevel <- tm_shape(plot_LocationsAtlanticCity20102019) + tm_dots("ForceLevel")
tmap_arrange(atlanticCity2000fLevel,atlanticCity2010fLevel)
newark2000age <- tm_shape(plot_LocationsNewark20002009) + tm_dots("Age")
newark2010age <- tm_shape(plot_LocationsNewark20102019) + tm_dots("Age")
tmap_arrange(newark2000age,newark2010age)
trenton2000age <- tm_shape(plot_LocationsTrenton20002009) + tm_dots("Age")
trenton2010age <- tm_shape(plot_LocationsTrenton20102019) + tm_dots("Age")
tmap_arrange(trenton2000age,trenton2010age)
camden2000age <- tm_shape(plot_LocationsCamden20002009) + tm_dots("Age")
camden2010age <- tm_shape(plot_LocationsCamden20102019) + tm_dots("Age")
tmap_arrange(camden2000age,camden2010age)
paterson2000age <- tm_shape(plot_LocationsPaterson20002009) + tm_dots("Age")
paterson2010age <- tm_shape(plot_LocationsPaterson20102019) + tm_dots("Age")
tmap_arrange(paterson2000age,paterson2010age)
atlanticCity2000age <- tm_shape(plot_LocationsAtlanticCity20002009) + tm_dots("Age")
atlanticCity2010age <- tm_shape(plot_LocationsAtlanticCity20102019) + tm_dots("Age")
tmap_arrange(atlanticCity2000age,atlanticCity2010age)
newark2000gender <- tm_shape(plot_LocationsNewark20002009) + tm_dots("Gender")
newark2010gender <- tm_shape(plot_LocationsNewark20102019) + tm_dots("Gender")
tmap_arrange(newark2000gender,newark2010gender)
trenton2000gender <- tm_shape(plot_LocationsTrenton20002009) + tm_dots("Gender")
trenton2010gender <- tm_shape(plot_LocationsTrenton20102019) + tm_dots("Gender")
tmap_arrange(trenton2000gender,trenton2010gender)
camden2000gender <- tm_shape(plot_LocationsCamden20002009) + tm_dots("Gender")
camden2010gender <- tm_shape(plot_LocationsCamden20102019) + tm_dots("Gender")
tmap_arrange(camden2000gender,camden2010gender)
paterson2000gender <- tm_shape(plot_LocationsPaterson20002009) + tm_dots("Gender")
paterson2010gender <- tm_shape(plot_LocationsPaterson20102019) + tm_dots("Gender")
tmap_arrange(paterson2000gender,paterson2010gender)
atlanticCity2000gender <- tm_shape(plot_LocationsAtlanticCity20002009) + tm_dots("Gender")
atlanticCity2010gender <- tm_shape(plot_LocationsAtlanticCity20102019) + tm_dots("Gender")
tmap_arrange(atlanticCity2000gender,atlanticCity2010gender)
Looking at the BarChart counts it seems like both Camden and Newark have a smaller number of police fatal encounters for the 2010-2019 decade compared to the 2000-2009 decade. Trenton seems to remain the same and both Paterson and Atlantic City show increases in police fatal encounters. A potential increase in crime and fatal encounters can be potentially attributed in Atlantic City to lower tourist demand at the Casinos. Also, gunshot and vehicles seem to be involved in the majority of the fatal encounters with police. Additionally, for the 2010-2019 decade there are cases where drug overdoses were a part of the fatal encounters. Drug overdoses were limited in fatal encounters in the 2000-2009 decade. This makes sense as deaths from the opiod epidemic across the US increased significantly during the 2010-2019 decade. There is no clear evidence that a decrease in crime rate reduces the chance of a fatal encounter in the presence of law enforcement.
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.