As a city worker myself I always hear there is not enough money in the budget. Therfore I decided where the city of NY could save money and spend it on more important angency or public, like streets or even on homeless people.
library (devtools)
## Loading required package: usethis
library (tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.7
## v tidyr 1.1.4 v stringr 1.4.0
## v readr 2.1.1 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(knitr)
file <- ("https://raw.githubusercontent.com/Eperez54/Dat-607/main/week%201/The%20Marshall%20Project%20-%20NYPD%20Claims%20Settled%20From%201.1.2010%20to%2012.31.2019.csv")
data <- read.csv(file)
data <- data.frame(data) %>% na.omit() # not counting N/A Values
head (data)
## Claimant.Name Claim.Number Claim.Type
## 1 Ady Encarnacion 2009PD029656 AUTOMOBILE ACCIDENT
## 2 Kathy Batka 2009PI023313 CIVIL RIGHTS CLAIMS
## 3 Paul Fox 2019PI012220 AUTOMOBILE ACCIDENT (PI)
## 4 Ingrid Conway 2009PI014930 PEACE OFFICER/POLICE ACTION (PI)
## 5 John P Dolan 2009PD012442 AUTOMOBILE ACCIDENT
## 6 Melvin Rennock 2009PI000487 CIVIL RIGHTS CLAIMS
## Date.of.Occurrence Date.Claim.Filed Occurrence.Location Occurrence.City
## 1 10/7/2009 11/16/2009 E 141 ST RIDER AV
## 2 7/26/2008 8/24/2009 7 AV & 33 ST & 34 ST
## 3 2/27/2019 4/29/2019 BAY RIDGE PY & 17 AV
## 4 5/1/2009 6/12/2009 111 BRIDGE ST
## 5 1/20/2009 3/19/2009 8 AV & 48 ST
## 6 9/5/2005 11/6/2008
## Occurrence.Borough Occurrence.State Agency
## 1 BRONX Police Department
## 2 MANHATTAN (NEW YORK) Police Department
## 3 BROOKLYN (KINGS) Police Department
## 4 BROOKLYN (KINGS) Police Department
## 5 MANHATTAN (NEW YORK) Police Department
## 6 BROOKLYN (KINGS) Police Department
## Defendant...Individual Defendant...Individual.with.Badge..
## 1
## 2
## 3
## 4
## 5
## 6
## Attorney Settlement.Date Settlement.Amount
## 1 1/4/2010 $489.01
## 2 Matthew Flamm 1/4/2010 $5,000.00
## 3 Harmon Linder & Rogowsky
## 4 Richard J Cardinale 1/4/2010 $15,000.00
## 5 1/4/2010 $3,006.46
## 6 Anthony C Ofodile 1/4/2010 $17,500.00
colnames(data)
## [1] "Claimant.Name" "Claim.Number"
## [3] "Claim.Type" "Date.of.Occurrence"
## [5] "Date.Claim.Filed" "Occurrence.Location"
## [7] "Occurrence.City" "Occurrence.Borough"
## [9] "Occurrence.State" "Agency"
## [11] "Defendant...Individual" "Defendant...Individual.with.Badge.."
## [13] "Attorney" "Settlement.Date"
## [15] "Settlement.Amount"
I want to only see vehicle accidents where NYPD was involved
VehicleAccident <- subset(data, data$Claim.Type == "AUTOMOBILE ACCIDENT")
head (VehicleAccident)
## Claimant.Name Claim.Number Claim.Type Date.of.Occurrence
## 1 Ady Encarnacion 2009PD029656 AUTOMOBILE ACCIDENT 10/7/2009
## 5 John P Dolan 2009PD012442 AUTOMOBILE ACCIDENT 1/20/2009
## 12 Steven Negron 2009PD025487 AUTOMOBILE ACCIDENT 9/22/2009
## 13 Silvia Giardina 2009PD019563 AUTOMOBILE ACCIDENT 5/6/2009
## 16 Nedeljkovic Uros Geico 2009PD013322 AUTOMOBILE ACCIDENT 4/15/2009
## 17 Cecil Horsford 2009PD008008 AUTOMOBILE ACCIDENT 11/23/2008
## Date.Claim.Filed Occurrence.Location Occurrence.City Occurrence.Borough
## 1 11/16/2009 E 141 ST RIDER AV BRONX
## 5 3/19/2009 8 AV & 48 ST MANHATTAN (NEW YORK)
## 12 10/9/2009 88 ST NORTHERN BL QUEENS
## 13 8/3/2009 444 UNION ST BROOKLYN (KINGS)
## 16 5/21/2009 298 CLASSON AV BROOKLYN (KINGS)
## 17 3/13/2009 LIBERTY AV & ELTON ST BROOKLYN (KINGS)
## Occurrence.State Agency Defendant...Individual
## 1 Police Department
## 5 Police Department
## 12 Police Department
## 13 Police Department
## 16 Police Department
## 17 Police Department
## Defendant...Individual.with.Badge.. Attorney Settlement.Date
## 1 1/4/2010
## 5 1/4/2010
## 12 1/5/2010
## 13 1/5/2010
## 16 1/5/2010
## 17 1/5/2010
## Settlement.Amount
## 1 $489.01
## 5 $3,006.46
## 12 $5,077.80
## 13 $575.00
## 16 $1,290.58
## 17 $2,095.36
How much does NYPD cost the city with bad officer drivers first we have to change the dollar amount to numeric
VehicleAccident$Settlement.Amount <- as.double(gsub('[$,]', '', VehicleAccident$Settlement.Amount))
meancost = mean(VehicleAccident$Settlement.Amount)
occurances = nrow(VehicleAccident)
sprintf("The mean value of settlement is $%.2f", meancost)
## [1] "The mean value of settlement is $2686.78"
sprintf("The total amount of accidents is %.0f", occurances)
## [1] "The total amount of accidents is 5239"
sprintf("The highest dollar amount in Settlement is $%.2f", max(VehicleAccident$Settlement.Amount))
## [1] "The highest dollar amount in Settlement is $450000.00"
options(scipen=999) # telling R to avoid all scientific notation by setting options
#(data$Claim.Type)
barplot(table(VehicleAccident$Occurrence.Borough), ylim=c(0,2000))
barplot(table(VehicleAccident$Occurrence.Borough), # Draw barplot with properly aligned legend
col = 1:nrow(table(VehicleAccident$Occurrence.Borough)),
legend.text = TRUE,
args.legend = list(x = "topright",
inset = c(- 0.15, 0)))
I believe that the NYPD could trim down this numbers. In a job where you spend more than 8 hours on the road the vehicle becomes your office. Furthermore I also believe that money spent in settlement could be better used in either training officers better driving skills to avoid accidents or invest in a program where officers who are repeat offenders would be mandated to go into training. If not then use on a different NYC agency.