-
Notifications
You must be signed in to change notification settings - Fork 0
/
Crime_project.Rmd
107 lines (74 loc) · 6.17 KB
/
Crime_project.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
title: "West Coast Fatal Police Shootings"
output: html_document
date: "2023-02-10"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(readr)
library(dplyr)
library(stringr)
library(ggplot2)
```
Data used in this project is from the Fatal Force Database(v2) from the Washington Post’s Github. The database includes two .csv files which contains data on fatal police shootings and the agencies in relation to the shootings in the United States. For the purpose of this project, I will be using the data set containing fatal police shootings.
This project will focus the variables of gender, race, mental health and if police body cameras were present at the crime.
```{r victums, include=FALSE}
victums <- read.csv("https://raw.githubusercontent.com/washingtonpost/data-police-shootings/master/v2/fatal-police-shootings-data.csv")
victums <- victums
victums[victums == ""] <- "undetermined"
```
```{r}
count_state <- sort(table(victums$state), decreasing =TRUE)
count_state
```
After uploading and glancing at the data, I saw a couple of blank cells, so I replaced the blank spaces with “undetermined”. Instead of looking at fatal police shootings in America as a whole, I wanted to explore the shootings along the West coast. West coast states include California, Oregon, and Washington State. California is the number one state with the most fatal police shootings, Washington State comes next at number 10 and Oregon at number 24 in the United States. While cleaning out the data, I removed the columns: id, county, city, name, flee_status, latitude, longitude, location_precision, race_source, and agency_ids. I then filtered the data so the new data only shows the West coast states selected with all crime reported till 12-31-2022, this is because the data is continuously being contributed to it everyday. I also specified, I want the genders to show both male and female. This new data set is named victims_wa.
```{r, include=FALSE}
victums_wa <- victums %>%
select(-c(id, county, city, name, flee_status, latitude, longitude, location_precision, race_source, agency_ids))%>%
filter((state == "WA"| state=="CA" | state=="OR" ) & (gender =="male" | gender == "female") & date <="2022-12-31")
```
```{r,}
#proportion individual males and females in the data
count_gender <- sort(table(victums_wa$gender))
prop.table(count_gender)
```
This first contingency table shows the proportions for male and females for all of the victims_wa dataset. It shows that females make 4.32% of the victims versus males making up 95.68% of the fatal shooting victims. This is not surprising considering that the majority of incarcerations are among men; therefore, showing men have more, and in this case, more aggressive encounters with law enforcement.
```{r}
#proportion of each race in the data
count_race <- sort(table(victums_wa$race))
prop.table(count_race)
```
The second contingency table shows the proportions of all the races included in the data. It can be seen that victims are majority White, 30.93%, and Hispainic, 31.87%. This makes up about 63% off the victims in the in the West coast
```{r, include=FALSE}
#partial tables for body cam
wa_b<- ftable(body_camera ~ race + gender , data=victums_wa)
wa_b
```
```{r,}
#estimated proportions for body cam
prop.table(wa_b)
```
This third contingency table is showing the estimated proportions of crimes related to race, gender, and if there was a police body camera at the time of the crime. Analyzing the table, it can be seen that for the majority of the crimes there has not been a body cam present at the time of the crime. As seen in earlier, the majority of the victims demographic of the west coast related to these crimes of white and Hispanic. Based on the table, the proportion of there NOT being a body cam at the crime is 25.3% and 25.4% for white and Hispanic respectively. This is slightly over 50% of the crimes committed on the West coast.
```{r, include=FALSE}
#partial tables for mental illness
wa_m<- ftable(was_mental_illness_related ~ race + gender , data=victums_wa)
wa_m
```
```{r}
#estimated proportions for mental illness
prop.table(wa_m)
```
This last contingency table shows the estimated proportions of victims' race, gender and if they had related to mental illness. Just at the glance it can be seen that not many of the victims did not have a documented mental illness or mental distress during the crime. However, it is important to note that white males seem to be more likely to have or experience mental illness or distress. White males make up about 9.38% of this population. In addition, the Hispanics show about 4% of the mental illness related. However, they make up the biggest proportion of the population that do not have any mental illness relations.
Based on my findings we can conclude that the majority of the West coast population is Hispanic and White. This is based on how high their percentages were based on victims. Based on the proportions of the body cams being present at the crime is extremely high in not being present. This continues to be an issue because there is not much evidence of the incidents to confirm the state of the victim before and during the crime. My interpretation of the mental illness related crimes show the victims being in the right mental state, although body cams would help this case a lot more, the percentages have me question why Hispanics percentage of having mental illness or mental distress at the time of the crime. Are Hispanics in less distress when these crimes happen because they are used to encounters with the law? Generally speaking, minorities are more likely to have encounters with the law compared to white people. Although whites help make up the majority of the victims of the West coast, when it comes to encounters with law enforcements are they more likely to become more distressed?
```{r, include=FALSE, eval=FALSE}
summary(victums_filtered2$age)
v <- victums_filtered2 %>%
ggplot( aes(date, gender, color=race)) +
geom_point() +
theme_bw()
ggplotly(v)
#average age is 37.22
#count_inspect <- sort(table(victums_filtered$state))
#count_inspect
```