#Introduction: This dataset contains information for the city of Chicago, IL on shootings, both fatal and non-fatal shootings. Specifically it covers homicides from 1991-present and non-fatal shootings from 2010-present. It has many variables including case number, date and time, address, primary victimization, gunshot, community, district, age, sex, race, location by gps coordinates and several others. This was sourced from the city of chicago.org via data.gov.
#This dataset shows individual victimizations, both fatal and non-fatal violence against persons in Chicago over the last couple of decades. “A victimization is considered a homicide victimization or non-fatal shooting victimization depending on its presence in CPD’s homicide victims data table or its shooting victims data table”1. “Each row represents a single victimization, i.e., a unique event when an individual became the victim of a homicide or non-fatal shooting. Each row does not represent a unique victim—if someone is victimized multiple times there will be multiple rows for each of those distinct events.2” This dataset is important because it represents the problem of gun violence in American and Chicago is one of the most prevalent cities in the country when it comes to homicides and worthy of study.
#load libaries and the dataset
library(tidyverse)
Warning: package 'tidyr' was built under R version 4.3.3
── 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.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ 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
Rows: 59158 Columns: 38
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (26): CASE_NUMBER, DATE, BLOCK, VICTIMIZATION_PRIMARY, INCIDENT_PRIMARY,...
dbl (12): ZIP_CODE, WARD, AREA, DISTRICT, BEAT, MONTH, DAY_OF_WEEK, HOUR, ST...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#clean and filter data to intended variables for use study, via graphing, etc.
Assuming "LONGITUDE" and "LATITUDE" are longitude and latitude, respectively
[[1]]
$title
[1] "Map of Incidents in District 11, Chicago, IL"
$caption
[1] "Source: City.Chicago.org"
attr(,"class")
[1] "labels"
#This map represents all non-fatal shootings in Chicago, IL from 2010-present. It shows the exact location of each incident, with a tooltip that tells the weather there was the following: primary incident, gunshot injury, race of victim, and that it was in District 11 in Chicago.
Statistical Analysis: We Will do a linear regresssion of some of variables from this dataset.
chicago_linear <-lm(ZIP_CODE ~ WARD, data = chicago)summary(chicago_linear)
Call:
lm(formula = ZIP_CODE ~ WARD, data = chicago)
Residuals:
Min 1Q Median 3Q Max
-31.857 -9.924 -6.801 7.791 198.015
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.063e+04 1.890e-01 320735.92 <2e-16 ***
WARD 1.173e-01 8.325e-03 14.09 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 22.16 on 59152 degrees of freedom
(4 observations deleted due to missingness)
Multiple R-squared: 0.003346, Adjusted R-squared: 0.003329
F-statistic: 198.6 on 1 and 59152 DF, p-value: < 2.2e-16
#The equation for this is 0.117(WARD) + 60630. THE p value is very small at 2x10^-16 and the r squared is very small also showing very little variabiltly at 0.00333.
library(GGally)
Warning: package 'GGally' was built under R version 4.3.3
Registered S3 method overwritten by 'GGally':
method from
+.gg ggplot2