library(tidyverse)
## ── 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.4 ✔ 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
t_data<- read.csv("traffic_data.csv")
summary(t_data$ViolPaid)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 0.00 0.00 68.11 144.00 679.00
summary(t_data$ViolFine)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 0.0 98.0 95.3 131.0 520.0
summary(t_data$ViolFees)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 81.0 134.0 119.6 144.0 679.0
summary(t_data$AmtDue)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 0.0 182.0 146.1 238.0 679.0
summary(t_data)
## FiledDate ViolationDate CitationNo ViolNo
## Length:9548 Length:9548 Length:9548 Min. :1.000
## Class :character Class :character Class :character 1st Qu.:1.000
## Mode :character Mode :character Mode :character Median :1.000
## Mean :1.347
## 3rd Qu.:2.000
## Max. :3.000
## ViolTime StatusDate StatusTime viol_conv_date
## Length:9548 Length:9548 Length:9548 Min. : 0
## Class :character Class :character Class :character 1st Qu.: 0
## Mode :character Mode :character Mode :character Median : 0
## Mean : 4207826
## 3rd Qu.: 0
## Max. :20250225
## OffenseCode OffenseDesc ViolStatus StatusDesc
## Length:9548 Length:9548 Length:9548 Length:9548
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
## CaseType Statute ViolLocation ViolPaid
## Length:9548 Length:9548 Length:9548 Min. : 0.00
## Class :character Class :character Class :character 1st Qu.: 0.00
## Mode :character Mode :character Mode :character Median : 0.00
## Mean : 68.11
## 3rd Qu.:144.00
## Max. :679.00
## ViolFine ViolFees AmtDue WarrantType
## Min. : 0.0 Min. : 0.0 Min. : 0.0 Length:9548
## 1st Qu.: 0.0 1st Qu.: 81.0 1st Qu.: 0.0 Class :character
## Median : 98.0 Median :134.0 Median :182.0 Mode :character
## Mean : 95.3 Mean :119.6 Mean :146.1
## 3rd Qu.:131.0 3rd Qu.:144.0 3rd Qu.:238.0
## Max. :520.0 Max. :679.0 Max. :679.0
## WarrantStatus ActiveWarrant OfficerAgency
## Mode:logical Length:9548 Length:9548
## NA's:9548 Class :character Class :character
## Mode :character Mode :character
##
##
##
hist(t_data$ViolPaid)
hist(t_data$ViolFine)
hist(t_data$ViolFees)
hist(t_data$AmtDue)
plot(t_data$ViolPaid,t_data$AmtDue)
plot(t_data$ViolFees,t_data$ViolFine)
ggplot(t_data,aes(x=ViolPaid,y=AmtDue)) + geom_point()
ggplot(t_data,aes(x=ViolFine,y=ViolFees)) + geom_point()
cor(t_data$ViolPaid,t_data$AmtDue)
## [1] -0.7447946
cor(t_data$ViolFees,t_data$ViolFine)
## [1] -0.3240773
Observations: Both sets of data have negative correlations. 1) As the amount Violation Paid increase, the Amount Due decreases. 2) The higher the Violation Fees are, the lower the Violation Fine is.