Setting Paths

pckgs <- c("tidyverse", "sf", "dplyr", "tigris","lubridate","purrr","ggplot2","RColorBrewer","hrbrthemes")
lapply(pckgs, library, character.only = T)

# set paths
OS <- .Platform$OS.type
if (OS == "unix"){
  input_dir <- "~/Dropbox/chyn_campos_bruhn/Gangs/data"
} else {
  input_dir <- "C:/Users/at3981/Dropbox/chyn_campos_bruhn/Gangs/data"
}

Gang Distance to Gang Presence data

Here, I have a dataset of each censusblock-year pair with its distance from a gang. Negative distance means that the gang is inside that census block. Missing values mean that the gang does not exist that year, so I imputed the missing distance value with a proxy positive value.

First, I transformed the data from a “wide” format to a “long” format, i.e, now each observation will be the distance from a certain census block to a certain gang. Then, I collapsed the data at block-year level and counted the number of gangs inside a block as the number of gangs with negative distance to that block. In this way, for each block-year, I have a list of gang names inside it and the number of gangs in that list.

For tract level, I did similar by collapsing block to tract level. However, since some blocks “share” the same gang, simple summation will not be accurate, so I count the number of distinct gangs in a tract.

load(str_interp("${input_dir}/gang_distance.rda"))
gang_data <- gang.distance


#fill in missing data with positive values since missing values mean no gangs
gang_data <- gang_data %>% mutate(across(.cols = 3:ncol(gang_data), ~case_when(is.na(.) ~ 1, TRUE ~ .)))

#make data from wide to long
gang_data_long <- gang_data %>% pivot_longer(-c(block.id,year))

#gang presence at block level
blocks_gang_presence <- gang_data_long %>% 
  group_by(block.id, year) %>%
  summarise(gang_list_block = paste(name[value < 0L], collapse = ','),
            no_gang = n_distinct(name[value < 0L])) %>% mutate(gang_presence = ifelse(no_gang > 0,1,0)) %>% arrange(block.id, year)

write.csv(blocks_gang_presence, file = str_interp("${input_dir}/block_gang_presence_with_names.csv"))

#gang presence at tract level
tract_gang_presence <- gang_data_long %>% mutate(gang = ifelse(value<0,1,0)) %>% 
  group_by(censustractid = substr(block.id, 1, 11), year) %>%
  summarise(no_gang = n_distinct(name[value < 0L]),
            gang_list_block = paste0(no_gang, ' (', paste(name[value < 0L], collapse = ','), ')'),
            blocks_with_gang = sum(gang)) %>% mutate(gang_presence = ifelse(no_gang > 0,1,0)) %>% arrange(censustractid, year)
write.csv(tract_gang_presence, file = str_interp("${input_dir}/tract_gang_presence_with_names.csv"))

The data now looks like this:

#load yearly data on gang presence - load here instead of using the above output if want to avoid having to run the above trunks again, which takes quite a few minutes
blocks_gang_presence <- read_csv(str_interp("${input_dir}/block_gang_presence_with_names.csv")) %>% 
  rename(census_block = block.id) %>% select(census_block, year, gang_list_block, no_gang, gang_presence)

knitr::kable(blocks_gang_presence[36:49,], col.names = c("Census Block ID", "Year","List of Gangs", "Number of Gangs Inside", "Gang presence"))
Census Block ID Year List of Gangs Number of Gangs Inside Gang presence
060371011101004 2009 NA 0 0
060371011101004 2010 NA 0 0
060371011101004 2011 NA 0 0
060371011101004 2016 NA 0 0
060371011101004 2019 NA 0 0
060371011101005 2006 NA 0 0
060371011101005 2007 NA 0 0
060371011101005 2008 NA 0 0
060371011101005 2009 NA 0 0
060371011101005 2010 NA 0 0
060371011101005 2011 NA 0 0
060371011101005 2016 NA 0 0
060371011101005 2019 NA 0 0
060371011101006 2006 Toonerville 1 1

LAPD Crime Data 2010-2019

First, I collapsed the monthly crime data into a yearly dataset so that I can merge it with the yearly gang presence data.

Note that the yearly data on gang presence covers the year 2006, 2007, 2008, 2009, 2011, 2016, 2019. However, our crime data covers the year 2010-2019 (LAPD) and 2005-2021 (LA Sheriff). Therefore, simply merging 1:1 on years and census block id will get a lot of crime data being thrown away. To avoid this, I imputed the missing gang presence value in years we do not have data by the closest earlier gang presence value of that particular census block. For example, gang presence data from the year 2013 will come from the gang presence data of the year 2011. Note that we do not have gang presence data on year 2005 so that year data from the Sheriff crime data will be unmerged.

After filling in, there will still be missing values from observations who only have one year of data and that year is not covered by the gang presence data. Thus, there is no other observations for us to impute and I removed those observations.

#load LAPD crime data
lapd_crime <- read_csv(str_interp("${input_dir}/crime/LAPD/output/panel_data_crimela_1019.csv"))

#collapse monthly data to yearly data.
lapd_crime_yearly <- lapd_crime %>% group_by(census_block, year) %>% 
  summarize(robbery = sum(robbery), homicide = sum(homicide), burglary = sum(burglary),
            shots_fired = sum(shots_fired), assault = sum(assault), rape = sum(rape), 
            theft = sum(theft), reckless_driving = sum(reckless_driving),
            vandalism = sum(vandalism), kidnapping = sum(kidnapping), order_violation = sum(order_violation),
            lynching = sum(lynching), counterfeit = sum(counterfeit), vandalism = sum(vandalism)) %>% 
  ungroup() %>% arrange(census_block, year)

#make a balanced panel data template 
unique_block <- data.frame(unique(lapd_crime_yearly$census_block)) %>% 
  rename(census_block = unique.lapd_crime_yearly.census_block.)
unique_block10 <- unique_block %>% slice(rep(1:n(), each = 10))
year_vec <- c(2010,2011,2012,2013,2014,2015,2016,2017,2018,2019)
year_vec10 <- rep(year_vec, nrow(unique_block))
unique_block10$year <- year_vec10

#merge the template with teh crime data and fill in NAs as 0 to get balanced panel
lapd_crime_yearly_balanced <- unique_block10 %>% 
  left_join(lapd_crime_yearly, by = c("census_block","year")) %>%  replace(is.na(.), 0)



#fill in the missing values with the closest earlier year
#version when missing block gang data is filled in with values from previous year
lapd_crime_gang <- lapd_crime_yearly_balanced %>% 
  left_join(blocks_gang_presence, by = c("census_block","year"))  %>% group_by(census_block) %>% 
  fill(c(gang_presence, no_gang), .direction = "down") %>% ungroup() %>% drop_na(gang_presence)
write.csv(lapd_crime_gang, file = str_interp("${input_dir}/balanced_lapd_crime_block_data.csv"))

#version when missing block gang data is not filled in 
lapd_crime_gang_unfilled <- lapd_crime_yearly_balanced %>% 
  left_join(blocks_gang_presence, by = c("census_block","year"))  %>% group_by(census_block)
write.csv(lapd_crime_gang_unfilled, file = str_interp("${input_dir}/balanced_lapd_crime_block_data_unfilled.csv"))

knitr::kable(head(lapd_crime_gang, 20))
census_block year robbery homicide burglary shots_fired assault rape theft reckless_driving vandalism kidnapping order_violation lynching counterfeit gang_list_block no_gang gang_presence
060371011101000 2010 0 0 2 0 2 0 0 0 0 0 1 0 0 NA 0 0
060371011101000 2011 0 0 2 0 2 0 0 0 0 0 1 0 0 NA 0 0
060371011101000 2012 0 0 1 0 3 0 0 0 2 0 0 0 0 NA 0 0
060371011101000 2013 0 0 1 0 1 0 0 0 0 0 0 0 0 NA 0 0
060371011101000 2014 0 0 1 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101000 2015 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101000 2016 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101000 2017 0 0 1 0 1 0 0 0 0 0 1 0 0 NA 0 0
060371011101000 2018 0 0 1 0 0 0 0 0 1 0 0 0 0 NA 0 0
060371011101000 2019 0 0 1 0 0 0 0 0 2 0 0 0 0 NA 0 0
060371011101001 2010 0 0 3 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2011 0 0 0 0 1 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2012 0 0 0 0 1 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2013 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2014 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2015 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2016 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2017 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2018 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0
060371011101001 2019 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0

Here, I documented the number of census block with and without gangs over the year.

lapd_crime_total <- lapd_crime_gang %>% group_by(year, gang_presence) %>% tally()
knitr::kable(lapd_crime_total, col.names = c("Year", "Presence of Gangs","Number of Census Blocks"))
Year Presence of Gangs Number of Census Blocks
2010 0 8908
2010 1 8909
2011 0 8477
2011 1 9340
2012 0 8477
2012 1 9340
2013 0 8477
2013 1 9340
2014 0 8477
2014 1 9340
2015 0 8477
2015 1 9340
2016 0 9313
2016 1 8504
2017 0 9313
2017 1 8504
2018 0 9313
2018 1 8504
2019 0 8301
2019 1 9516

After merging the data, I collapsed it on the year and gang presence variable to calculate some summary statistics of different crime types. Specifically, I calculated the sum, mean, and standard deviation. Note that the mean for a given crime type here is calculated as:

\[ \overline{Crime_{kjt}} = \frac{\sum_i Case_{ikjt}}{\sum_{j \in \{J_0,J_1\}} Block_{jt}} \] where the subscript \(i\) denotes a particular case of that crime type \(k\) in blocks of gang presence status \(j\), and \(t\) denotes year. \(J_0\) is the set of census blocks without gang presence, and \(J_1\) is the set of census blocks with gang presence. In words, the average for each crime type here is the count of all cases of that crime type within all the census blocks with/without gang presence, divided by the number of census blocks with/without gang presence. For illustration purposes, I multiplied all of these mean by 100.

lapd_crime_grouped <- lapd_crime_gang  %>% 
  group_by(year, gang_presence) %>% summarise(count_robbery = sum(robbery), mean_robbery = 100*mean(robbery), sd_robbery = sd(robbery),
                                             count_homicide = sum(homicide), mean_homicide = 100*mean(homicide), sd_homicide = sd(homicide),
                                             count_burglary = sum(burglary), mean_burglary = 100*mean(burglary), sd_burglary = sd(burglary),
                                             count_shots_fired = sum(shots_fired), mean_shots_fired = 100*mean(shots_fired), sd_shots_fired = sd(shots_fired),
                                             count_assault = sum(assault), mean_assault = 100*mean(assault), sd_assault = sd(assault),
                                             count_rape = sum(rape), mean_rape = 100*mean(rape), sd_rape = sd(rape),
                                             count_theft = sum(theft), mean_theft = 100*mean(theft), sd_theft = sd(theft),
                                             count_counterfeit = sum(counterfeit), mean_counterfeit = 100*mean(counterfeit), sd_counterfeit = sd(counterfeit),
                                             count_reckless_driving = sum(reckless_driving), mean_reckless_driving = 100*mean(reckless_driving), sd_reckless_driving = sd(reckless_driving),
                                             count_lynching = sum(lynching), mean_lynching = 100*mean(lynching), sd_lynching = sd(lynching),
                                             count_vandalism = sum(vandalism), mean_vandalism = 100*mean(vandalism), sd_vandalism = sd(vandalism),
                                             count_order_violation = sum(order_violation), mean_order_violation = 100*mean(order_violation), sd_order_violation = sd(order_violation),
                                             count_kidnapping = sum(kidnapping), mean_kidnapping = 100*mean(kidnapping), sd_kidnapping = sd(kidnapping)) %>% ungroup() %>% 
  mutate(gang_present = as.factor(gang_presence), `Presence of Gangs` = ifelse(gang_presence == 1, "Yes","No"))

knitr::kable(lapd_crime_grouped[,1:41] , col.names = c('Year', 'Presence of Gangs', 'Count of Robbery', 'Average:Robbery', 'SD:Robbery','Count of Homicide', 'Average:Homicide', 'SD:Homicide', 'Count of Burglary', 'Average:Burglary', 'SD:Burglary','Count of Shots fired', 'Average:Shots fired', 'SD:Shots fired','Count of Assault', 'Average:Assualt', 'SD:Assault','Count of Sexual cases', 'Average:Sexual cases', 'SD:sexual cases','Count of Theft', 'Average:Theft', 'SD:Theft','Count of Counterfeit', 'Average:Counterfeit', 'SD:Counterfeit','Count of Reckless Driving', 'Average:Reckless Driving', 'SD:Reckless Driving','Count of Lynching', 'Average:Lynching', 'SD:Lynching','Count of Vandalism', 'Average:Vandalism', 'SD:Vandalism','Count of Order violation', 'Average:Order violation', 'SD:Order violation','Count of Kidnapping', 'Average:Kidnapping', 'SD:Kidnapping'))
Year Presence of Gangs Count of Robbery Average:Robbery SD:Robbery Count of Homicide Average:Homicide SD:Homicide Count of Burglary Average:Burglary SD:Burglary Count of Shots fired Average:Shots fired SD:Shots fired Count of Assault Average:Assualt SD:Assault Count of Sexual cases Average:Sexual cases SD:sexual cases Count of Theft Average:Theft SD:Theft Count of Counterfeit Average:Counterfeit SD:Counterfeit Count of Reckless Driving Average:Reckless Driving SD:Reckless Driving Count of Lynching Average:Lynching SD:Lynching Count of Vandalism Average:Vandalism SD:Vandalism Count of Order violation Average:Order violation SD:Order violation Count of Kidnapping Average:Kidnapping SD:Kidnapping
2010 0 2598 29.16480 1.0195297 48 0.5388415 0.0791085 12769 143.3431 2.562731 115 1.2909744 0.1242539 10213 114.64975 2.716371 1415 15.88460 0.5369718 278 3.120790 0.6955668 52 0.5837449 0.0804839 7 0.0785811 0.0280229 0 0.0000000 0.0000000 5950 66.79389 1.395423 1152 12.93220 0.6233564 125 1.4032330 0.1232243
2010 1 5751 64.55270 1.5900798 189 2.1214502 0.1487074 13897 155.9883 2.412764 374 4.1980020 0.2322020 20769 233.12381 4.146204 2700 30.30643 0.7813013 252 2.828600 0.7004771 47 0.5275564 0.0724453 14 0.1571445 0.0617602 3 0.0336738 0.0183484 9120 102.36839 1.751899 2022 22.69615 0.8499375 261 2.9296217 0.1905236
2011 0 2045 24.12410 0.8517853 42 0.4954583 0.0735020 11516 135.8499 2.491740 85 1.0027132 0.1129570 8949 105.56801 2.663257 1229 14.49805 0.5429651 283 3.338445 0.6946122 29 0.3421022 0.0677460 6 0.0707798 0.0307138 1 0.0117966 0.0108612 5348 63.08836 1.418879 1014 11.96178 0.6141239 89 1.0498997 0.1053465
2011 1 5548 59.40043 1.6047654 184 1.9700214 0.1486547 13317 142.5803 2.313977 385 4.1220557 0.2217265 20751 222.17345 4.026385 2616 28.00857 0.7474335 259 2.773019 0.7218180 45 0.4817987 0.0882806 3 0.0321199 0.0179201 4 0.0428266 0.0206913 9008 96.44540 1.735361 2037 21.80942 0.7432274 261 2.7944325 0.1873235
2012 0 1879 22.16586 0.8402695 52 0.6134246 0.0810510 11199 132.1104 2.445343 94 1.1088829 0.1184679 8673 102.31214 2.573448 1252 14.76938 0.5125936 277 3.267665 0.6970196 43 0.5072549 0.0988262 4 0.0471865 0.0217186 2 0.0235933 0.0217225 5286 62.35697 1.373063 979 11.54890 0.6779700 86 1.0145099 0.1025440
2012 1 4888 52.33405 1.4393515 183 1.9593148 0.1497453 13111 140.3747 2.272252 427 4.5717345 0.2425634 20717 221.80942 4.102482 2728 29.20771 0.7723688 248 2.655246 0.6565309 38 0.4068522 0.0669381 6 0.0642398 0.0253388 4 0.0428266 0.0206913 8825 94.48608 1.673813 1964 21.02784 0.7446862 252 2.6980728 0.1783918
2013 0 1703 20.08965 0.8016377 39 0.4600684 0.0693975 10853 128.0288 2.403593 79 0.9319335 0.1031956 8383 98.89112 2.515946 1217 14.35649 0.5646376 314 3.704141 0.7192139 49 0.5780347 0.2386441 1 0.0117966 0.0108612 2 0.0235933 0.0153592 4893 57.72089 1.342340 998 11.77303 0.6519388 90 1.0616964 0.1134244
2013 1 4208 45.05353 1.3293715 156 1.6702355 0.1354716 12589 134.7859 2.250146 367 3.9293362 0.2476097 19612 209.97859 3.973073 2514 26.91649 0.7144748 326 3.490364 0.9805159 35 0.3747323 0.0661525 10 0.1070664 0.0327052 6 0.0642398 0.0327164 8651 92.62313 1.699952 1960 20.98501 0.7513912 214 2.2912206 0.1626610
2014 0 1623 19.14592 0.7408608 44 0.5190516 0.0839754 9714 114.5924 2.207887 97 1.1442727 0.1208990 9203 108.56435 2.837627 1262 14.88734 0.5587396 322 3.798514 0.6496967 25 0.2949157 0.0542292 3 0.0353899 0.0242853 1 0.0117966 0.0108612 5066 59.76171 1.397955 1087 12.82293 0.7677132 81 0.9555267 0.1054363
2014 1 4282 45.84582 1.3399110 164 1.7558887 0.1415501 11639 124.6146 2.099238 378 4.0471092 0.2343054 21245 227.46253 4.267812 2556 27.36617 0.7118624 410 4.389722 1.5379694 26 0.2783726 0.0566091 8 0.0856531 0.0292556 3 0.0321199 0.0231362 8964 95.97430 1.722748 2243 24.01499 0.8634308 213 2.2805139 0.1681779
2015 0 1901 22.42539 0.9632642 39 0.4600684 0.0710773 10516 124.0533 2.397708 84 0.9909166 0.1234472 9888 116.64504 3.066783 1308 15.42999 0.5823193 334 3.940073 0.6977717 25 0.2949157 0.0563628 8 0.0943730 0.0307075 0 0.0000000 0.0000000 5192 61.24808 1.491679 812 9.57886 0.5831336 69 0.8139672 0.0961986
2015 1 4687 50.18201 1.4412494 183 1.9593148 0.1546698 12237 131.0171 2.335002 396 4.2398287 0.2312020 22990 246.14561 4.659967 2586 27.68737 0.7682536 389 4.164882 1.0609844 36 0.3854390 0.0636718 19 0.2034261 0.0473761 5 0.0535332 0.0231323 9722 104.08994 1.920978 1931 20.67452 0.7315401 225 2.4089936 0.1686348
2016 0 2267 24.34232 0.9552464 55 0.5905723 0.0964775 12172 130.6990 2.655057 118 1.2670461 0.1183837 10311 110.71620 2.996796 1405 15.08644 0.5829990 303 3.253517 0.5888736 36 0.3865564 0.0654262 16 0.1718029 0.0414157 1 0.0107377 0.0103623 5990 64.31869 1.540522 1060 11.38194 0.5599145 87 0.9341780 0.1117012
2016 1 5327 62.64111 1.7087783 171 2.0108184 0.1554837 11963 140.6750 2.467001 469 5.5150517 0.2813616 23244 273.33020 4.903888 2687 31.59690 0.8128388 446 5.244591 1.4461444 27 0.3174976 0.0562607 15 0.1763876 0.0419639 5 0.0587959 0.0286861 10117 118.96754 2.132974 2124 24.97648 0.9233533 205 2.4106303 0.1788730
2017 0 2482 26.65092 1.0206483 55 0.5905723 0.0846176 13185 141.5763 2.815263 120 1.2885214 0.1352950 11047 118.61913 3.121452 1489 15.98840 0.5921280 278 2.985075 0.3863130 20 0.2147536 0.0485585 12 0.1288521 0.0358748 0 0.0000000 0.0000000 6156 66.10115 1.604494 1088 11.68259 0.5720146 88 0.9449157 0.1062726
2017 1 5547 65.22813 1.8032337 155 1.8226717 0.1463720 12687 149.1886 2.701885 394 4.6331138 0.2708430 23982 282.00847 5.164821 2565 30.16228 0.8084391 399 4.691910 0.9736188 22 0.2587018 0.0507999 17 0.1999059 0.0446688 4 0.0470367 0.0216841 10008 117.68579 2.093487 2261 26.58749 0.8971486 170 1.9990593 0.1481397
2018 0 2386 25.62010 0.9841257 50 0.5368839 0.0852853 12760 137.0128 2.862566 135 1.4495866 0.1394342 11478 123.24707 3.538747 1467 15.75217 0.5929421 320 3.436057 0.4839570 16 0.1718029 0.0485756 11 0.1181145 0.0343493 0 0.0000000 0.0000000 6019 64.63009 1.551968 1157 12.42349 0.6215334 69 0.7408998 0.0870039
2018 1 5256 61.80621 1.6634183 153 1.7991533 0.1431518 12156 142.9445 2.536008 343 4.0333960 0.2220274 23921 281.29116 5.085895 2430 28.57479 0.7534961 392 4.609596 0.9021210 25 0.2939793 0.0541433 20 0.2351834 0.0484415 3 0.0352775 0.0187801 9799 115.22813 2.035779 2189 25.74083 0.8992224 147 1.7285983 0.1415871
2019 0 1910 23.00928 0.9401694 41 0.4939164 0.0766760 10248 123.4550 2.693552 94 1.1323937 0.1236666 9602 115.67281 3.625298 1115 13.43212 0.5480779 281 3.385134 0.5979370 21 0.2529816 0.0502366 6 0.0722804 0.0268769 2 0.0240935 0.0155211 4890 58.90857 1.501941 933 11.23961 0.5690972 64 0.7709914 0.0888389
2019 1 5167 54.29802 1.4902528 152 1.5973098 0.1350627 11770 123.6864 2.231012 450 4.7288777 0.2578703 25210 264.92224 4.846949 2315 24.32745 0.6727032 451 4.739386 1.0855002 21 0.2206810 0.0491158 19 0.1996637 0.0446415 2 0.0210172 0.0144966 10351 108.77470 1.927256 2442 25.66204 0.8843435 173 1.8179908 0.1520070

Figures: Average cases of crimes over the years by gang presence - reported by LAPD

#define custom color scale
myColors <- brewer.pal(6, "PuOr")
names(myColors) <- levels(lapd_crime_grouped$`Presence of Gangs`)
custom_colors <- scale_colour_manual(name = "Presence of Gangs", values = myColors)

#plots of average cases of crimes reported by LAPD
lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_robbery, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("")   + scale_x_continuous(breaks=seq(2010,2019,1)) +
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Robbery (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_homicide, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Homicide (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_burglary, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Burglary (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_shots_fired, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) +
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Shots Fired (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_assault, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) +
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Assault (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_rape, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) +
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Rape (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_theft, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Theft (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_counterfeit, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Counterfeit (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_reckless_driving, color = `Presence of Gangs`)) +
  geom_line() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Reckless Driving (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_lynching, color = `Presence of Gangs`)) +
  geom_line()  + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Lynching (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_vandalism, color = `Presence of Gangs`)) +
  geom_line() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Vandalism (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_order_violation, color = `Presence of Gangs`)) +
  geom_line() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1)) + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Order Violation (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

lapd_crime_grouped %>% ggplot(aes(x = year, y = mean_kidnapping, color = `Presence of Gangs`)) +
  geom_line() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2010,2019,1))  + 
  custom_colors + theme_ipsum() + ggtitle("LAPD - Average Cases of Kidnapping (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

Sheriff Crime Data 2005-2021

The below section repeats all the same steps with the Sheriff crime data. However, it seems that there are very few census blocks with gang presence in this data. This means that the count of crimes in census blocks without gang presence is much larger than the corresponding figure from blocks with gangs. Even when taking the mean, the pattern still holds for all crime types.

#Sheriff Crime Data
sheriff_crime <- read_csv(str_interp("${input_dir}/crime/Sheriff/output/panel_data_crimela_0521.csv"))
#collapse to yearly data
sheriff_crime_yearly <- sheriff_crime %>% group_by(census_block, year) %>% 
  summarize(robbery = sum(robbery), homicide = sum(homicide), burglary = sum(burglary),
            weapons = sum(weapons), assault = sum(assault), rape_sexual = sum(rape_sexual), 
            theft = sum(theft), reckless_driving = sum(reckless_driving), fraud = sum(fraud), 
            vandalism = sum(vandalism), alcohol = sum(alcohol)) %>% 
  ungroup() %>% arrange(census_block, year)

#join with gang presnce data
sheriff_crime_gang <- sheriff_crime_yearly %>% 
  left_join(blocks_gang_presence, by = c("census_block","year")) %>% group_by(census_block) %>% 
  fill(c(gang_presence), .direction = "down") %>% ungroup() %>% drop_na(gang_presence)
sheriff_crime_total <- sheriff_crime_gang %>% group_by(year, gang_presence) %>% tally()
knitr::kable(sheriff_crime_total, col.names = c("Year", "Presence of Gangs","Number of Census Blocks"))
Year Presence of Gangs Number of Census Blocks
2006 0 2849
2006 1 731
2007 0 3006
2007 1 869
2008 0 2839
2008 1 1023
2009 0 2769
2009 1 922
2010 0 2964
2010 1 960
2011 0 2799
2011 1 1308
2012 0 2598
2012 1 963
2013 0 2543
2013 1 948
2014 0 2516
2014 1 936
2015 0 2556
2015 1 916
2016 0 2713
2016 1 1158
2017 0 2510
2017 1 811
2018 0 2427
2018 1 663
2019 0 2745
2019 1 611
2020 0 2620
2020 1 482
2021 0 2610
2021 1 427
sheriff_crime_grouped <- sheriff_crime_gang %>% group_by(year, gang_presence) %>% summarise(count_robbery = sum(robbery), mean_robbery = 100*mean(robbery), sd_robbery = sd(robbery),
                                                       count_homicide = sum(homicide), mean_homicide = 100*mean(homicide), sd_homicide = sd(homicide),
                                                       count_burglary = sum(burglary), mean_burglary = 100*mean(burglary), sd_burglary = sd(burglary),
                                                       count_weapons = sum(weapons), mean_weapons = 100*mean(weapons), sd_weapons = sd(weapons),
                                                       count_assault = sum(assault), mean_assault = 100*mean(assault), sd_assault = sd(assault),
                                                       count_rape_sexual = sum(rape_sexual), mean_rape_sexual = 100*mean(rape_sexual), sd_rape_sexual = sd(rape_sexual),
                                                       count_theft = sum(theft), mean_theft = 100*mean(theft), sd_theft = sd(theft),
                                                       count_reckless_driving = sum(reckless_driving), mean_reckless_driving = 100*mean(reckless_driving), sd_reckless_driving = sd(reckless_driving),
                                                       count_fraud = sum(fraud), mean_fraud = 100*mean(fraud), sd_fraud = sd(fraud),
                                                       count_vandalism = sum(vandalism), mean_vandalism = 100*mean(vandalism), sd_vandalism = sd(vandalism),
                                                       count_alcohol = sum(alcohol), mean_alcohol = 100*mean(alcohol), sd_alcohol = sd(alcohol)) %>% ungroup() %>% 
  mutate(gang_presence = as.factor(gang_presence), `Presence of Gangs` = ifelse(gang_presence == 1, "Yes","No")) 

knitr::kable(sheriff_crime_grouped[-36], col.names = c('Year', 'Presence of Gangs', 'Count of Robbery', 'Average:Robbery', 'SD:Robbery','Count of Homicide', 'Average:Homicide', 'SD:Homicide', 'Count of Burglary', 'Average:Burglary', 'SD:Burglary','Count of Weapon cases', 'Average:Weapon cases', 'SD:Weapon cases','Count of Assault', 'Average:Assualt', 'SD:Assault','Count of Sexual cases', 'Average:Sexual cases', 'SD:sexual cases','Count of Theft', 'Average:Theft', 'SD:Theft','Count of Reckless Driving', 'Average:Reckless Driving', 'SD:Reckless Driving','Count of Fraud', 'Average:Fraud', 'SD:Fraud','Count of Vandalism', 'Average:Vandalism', 'SD:Vandalism','Count of Alcohol', 'Average:Alcohol', 'SD:Alcohol'))
Year Presence of Gangs Count of Robbery Average:Robbery SD:Robbery Count of Homicide Average:Homicide SD:Homicide Count of Burglary Average:Burglary SD:Burglary Count of Weapon cases Average:Weapon cases SD:Weapon cases Count of Assault Average:Assualt SD:Assault Count of Sexual cases Average:Sexual cases SD:sexual cases Count of Theft Average:Theft SD:Theft Count of Reckless Driving Average:Reckless Driving SD:Reckless Driving Count of Fraud Average:Fraud SD:Fraud Count of Vandalism Average:Vandalism SD:Vandalism Count of Alcohol Average:Alcohol SD:Alcohol
2006 0 1183 41.523342 1.1304920 69 2.4219024 0.1668959 1666 58.476658 1.1815201 943 33.099333 3.4583636 2845 99.85960 20.7569874 434 15.233415 0.9145145 3630 127.41313 4.561260 282 9.8982099 0.5287012 922 32.362232 0.7720586 2180 76.51808 3.3971602 647 22.709723 1.1477977
2006 1 93 12.722298 0.5429098 0 0.0000000 0.0000000 65 8.891929 0.4843019 59 8.071135 0.3356409 173 23.66621 0.8226731 31 4.240766 0.2711855 208 28.45417 2.298545 17 2.3255814 0.1596428 51 6.976744 0.2654587 253 34.61012 2.1938383 10 1.367989 0.1162378
2007 0 1266 42.115769 1.2504661 60 1.9960080 0.1445659 1797 59.780439 1.1325975 936 31.137725 3.4894922 2791 92.84764 18.0143373 465 15.469062 0.6047700 4171 138.75582 5.901902 292 9.7139055 0.4229818 1031 34.298071 0.8205730 2365 78.67598 3.2522519 767 25.515635 1.1247178
2007 1 122 14.039125 0.6447879 0 0.0000000 0.0000000 87 10.011508 0.4429296 83 9.551208 0.3856177 160 18.41197 0.7639191 22 2.531646 0.1712082 260 29.91945 1.548081 23 2.6467204 0.1743694 42 4.833141 0.2301324 574 66.05293 6.9829331 37 4.257767 0.2434029
2008 0 1169 41.176471 1.1686001 53 1.8668545 0.1404846 1869 65.833040 1.3059980 988 34.800986 4.2856993 2622 92.35646 18.4437550 508 17.893625 0.7135802 4119 145.08630 4.898508 302 10.6375484 0.4543559 1122 39.520958 0.9645906 2258 79.53505 3.4678681 965 33.990842 1.2886708
2008 1 155 15.151515 0.7305971 7 0.6842620 0.0824770 106 10.361681 0.6931427 128 12.512219 0.7520255 304 29.71652 3.3088953 31 3.030303 0.1825579 352 34.40860 2.630337 30 2.9325513 0.1905811 87 8.504399 0.2927720 335 32.74682 2.2346012 55 5.376344 0.2542073
2009 0 1075 38.822680 1.0911587 40 1.4445648 0.1252486 1827 65.980498 1.3729341 840 30.335861 4.7254530 2449 88.44348 18.2975272 410 14.806790 0.6068290 4108 148.35681 6.653574 255 9.2091008 0.4092133 965 34.850126 0.9470627 2172 78.43987 3.7288075 744 26.868906 1.4332568
2009 1 146 15.835141 0.7859244 2 0.2169197 0.0465494 71 7.700651 0.4882246 155 16.811280 2.5200483 277 30.04338 3.1263268 30 3.253796 0.2004985 255 27.65727 1.923192 13 1.4099783 0.1268370 51 5.531453 0.2425412 262 28.41649 2.0074640 36 3.904555 0.2648302
2010 0 1164 39.271255 1.1415041 54 1.8218623 0.1458345 2006 67.678812 1.2484703 815 27.496626 3.1178291 2509 84.64912 14.2306248 447 15.080972 0.8701733 4216 142.24022 7.353592 310 10.4588394 0.5056474 988 33.333333 0.9711788 1930 65.11471 1.8829471 810 27.327935 1.1178670
2010 1 125 13.020833 0.5872507 3 0.3125000 0.0558434 107 11.145833 0.5375125 117 12.187500 0.9819755 247 25.72917 2.1134282 43 4.479167 0.2119328 330 34.37500 2.003793 20 2.0833333 0.1814762 56 5.833333 0.2637923 234 24.37500 1.1807292 57 5.937500 0.5081357
2011 0 901 32.190068 0.9626639 28 1.0003573 0.1161078 1703 60.843158 1.1707113 624 22.293676 1.7865841 2117 75.63416 12.2659041 390 13.933548 0.6841562 4360 155.76992 7.124203 341 12.1829225 0.5503447 876 31.296892 0.9207013 1604 57.30618 1.7508100 674 24.080029 1.1693153
2011 1 250 19.113150 0.6765371 13 0.9938838 0.0992350 331 25.305810 0.7601583 202 15.443425 0.4876472 360 27.52294 0.8357530 66 5.045872 0.2514985 709 54.20489 2.803251 43 3.2874618 0.2170724 91 6.957186 0.2662744 331 25.30581 0.6737156 126 9.633028 0.5983031
2012 0 954 36.720554 1.0237243 22 0.8468052 0.0916492 1732 66.666667 1.3313745 610 23.479600 1.8887803 2541 97.80600 18.7705862 394 15.165512 0.7760984 4641 178.63741 7.386269 307 11.8167821 0.5376551 999 38.452656 0.9742266 1586 61.04696 2.3049891 762 29.330254 1.1392300
2012 1 261 27.102804 1.0217294 9 0.9345794 0.0962708 319 33.125649 0.8341273 145 15.057113 0.4595569 452 46.93666 1.3394100 83 8.618899 0.3588013 754 78.29699 3.712042 15 1.5576324 0.1320176 128 13.291797 0.4836049 310 32.19107 0.8003428 170 17.653167 1.1417195
2013 0 801 31.498230 0.9558917 31 1.2190326 0.1097564 1662 65.355879 1.2562644 622 24.459300 2.2539294 2815 110.69603 26.0007180 356 13.999213 0.9256726 4134 162.56390 4.909472 259 10.1848211 0.5527349 879 34.565474 0.8328356 1589 62.48525 3.8974920 731 28.745576 1.2010469
2013 1 282 29.746835 1.1397187 11 1.1603376 0.1071487 314 33.122363 0.9316651 146 15.400844 0.4497034 470 49.57806 1.5369381 79 8.333333 0.3850653 917 96.72996 5.415569 19 2.0042194 0.1475574 115 12.130802 0.4348222 344 36.28692 1.0535669 163 17.194093 1.0831208
2014 0 763 30.325914 0.9292279 18 0.7154213 0.0842962 1428 56.756757 1.0402465 591 23.489666 2.6014353 3140 124.80127 29.4909444 329 13.076312 0.7466237 4052 161.04928 5.640181 242 9.6184420 0.4585062 809 32.154213 0.7688965 1617 64.26868 4.3015451 652 25.914149 1.1549943
2014 1 265 28.311966 1.0206286 14 1.4957265 0.1214467 335 35.790598 0.9893019 139 14.850427 0.5215751 526 56.19658 1.3868774 65 6.944444 0.2860128 810 86.53846 3.623901 24 2.5641026 0.1999589 108 11.538462 0.3722147 414 44.23077 1.3415948 192 20.512821 1.0810054
2015 0 712 27.856025 0.8842313 26 1.0172144 0.1114493 1406 55.007825 1.1136214 669 26.173709 3.2648216 3446 134.82003 33.2024809 297 11.619718 0.7302493 4275 167.25352 6.003095 184 7.1987480 0.3980158 878 34.350548 0.8459417 1829 71.55712 4.9573611 447 17.488263 0.8221083
2015 1 277 30.240175 0.9924495 13 1.4192140 0.1183470 233 25.436681 0.8295977 162 17.685589 0.5719771 511 55.78603 1.4447695 81 8.842795 0.4126912 786 85.80786 4.576198 15 1.6375546 0.1353173 111 12.117904 0.4069735 387 42.24891 1.5391065 136 14.847162 0.8732878
2016 0 895 32.989311 0.9824691 39 1.4375230 0.1190538 1381 50.903059 1.1239595 749 27.607814 2.8273982 3703 136.49097 34.0119748 325 11.979359 1.0736292 4788 176.48360 5.160905 153 5.6395135 0.2952247 890 32.805013 0.7903444 2148 79.17435 4.9036188 1019 37.559897 7.2047659
2016 1 331 28.583765 1.2411790 9 0.7772021 0.0878538 240 20.725389 0.6795310 151 13.039724 0.4191917 550 47.49568 1.4789721 71 6.131261 0.3092451 866 74.78411 3.604517 14 1.2089810 0.1309190 107 9.240069 0.3541495 451 38.94646 1.3269859 121 10.449050 0.9400145
2017 0 954 38.007968 1.1196644 29 1.1553785 0.1068871 1503 59.880478 1.2942828 763 30.398406 2.8566844 3338 132.98805 31.2684468 348 13.864542 1.1991347 4517 179.96016 5.805613 141 5.6175299 0.2759666 778 30.996016 0.7604332 1999 79.64143 4.4193751 764 30.438247 3.7784105
2017 1 204 25.154131 0.7325632 8 0.9864365 0.0988894 218 26.880395 0.7432002 175 21.578298 0.5679049 409 50.43157 1.9903269 52 6.411837 0.2868859 668 82.36745 3.613381 9 1.1097411 0.1048227 96 11.837238 0.3827068 417 51.41800 1.7765923 74 9.124538 0.6258307
2018 0 808 33.292130 1.0112719 25 1.0300783 0.1009895 1238 51.009477 1.0444575 759 31.273177 3.2189692 3601 148.37248 37.6342341 309 12.731768 1.0894947 4629 190.72930 7.322287 205 8.4466419 0.4556526 743 30.613927 0.7798838 1763 72.64112 4.4964187 508 20.931191 1.3864956
2018 1 151 22.775264 0.6579853 5 0.7541478 0.0865789 179 26.998492 0.7779754 160 24.132730 0.6836322 339 51.13122 2.3595487 23 3.469080 0.2205531 623 93.96682 3.500019 7 1.0558069 0.1161186 82 12.368024 0.3844764 347 52.33786 1.5659653 55 8.295626 0.4438866
2019 0 901 32.823315 1.0328535 32 1.1657559 0.1073586 1128 41.092896 0.8942789 863 31.438980 2.9831696 3081 112.24044 23.4843543 329 11.985428 0.7948376 4693 170.96539 6.474147 188 6.8488160 0.3687522 800 29.143898 0.7356124 1864 67.90528 2.5860022 650 23.679417 1.6359754
2019 1 62 10.147300 0.4466793 5 0.8183306 0.0901645 70 11.456629 0.7377195 102 16.693944 0.4453258 164 26.84124 2.0252425 20 3.273322 0.2603445 286 46.80851 3.092065 6 0.9819967 0.0986888 33 5.400982 0.2535572 140 22.91326 1.2930593 34 5.564648 0.4325070
2020 0 774 29.541985 0.8394040 50 1.9083969 0.1368463 1154 44.045802 0.9804721 911 34.770992 3.4434412 2519 96.14504 17.2746507 209 7.977099 0.6180213 3848 146.87023 3.756244 123 4.6946565 0.2526874 601 22.938931 0.6051633 1869 71.33588 1.6155663 401 15.305343 0.6846446
2020 1 37 7.676348 0.3164241 2 0.4149378 0.0643487 73 15.145228 0.8332288 115 23.858921 0.5759603 118 24.48133 1.5130149 10 2.074689 0.1426839 159 32.98755 1.026215 12 2.4896266 0.1559709 25 5.186722 0.2399901 131 27.17842 1.1971868 49 10.165975 1.0556438
2021 0 675 25.862069 0.7553136 76 2.9118774 0.1748755 1098 42.068965 0.9932858 770 29.501916 1.6336387 2138 81.91571 11.3523086 144 5.517241 0.2627034 3918 150.11494 4.284734 143 5.4789272 0.2924665 735 28.160919 0.6965989 1724 66.05364 1.5877592 282 10.804598 0.5080913
2021 1 34 7.962529 0.3260690 2 0.4683841 0.0683582 70 16.393443 0.8887991 110 25.761124 0.6601728 130 30.44496 1.6939699 10 2.341920 0.1923771 196 45.90164 1.435657 4 0.9367681 0.0964454 24 5.620609 0.2305894 131 30.67916 1.1716630 15 3.512881 0.2492857
#define custom color scale
myColors <- brewer.pal(4, "Spectral")
names(myColors) <- levels(sheriff_crime_grouped$`Presence of Gangs`)
custom_colors <- scale_colour_manual(name = "Presence of Gangs", values = myColors)

#visualization
sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_robbery, color = `Presence of Gangs`)) +
  geom_line() + theme(legend.title = element_text(size=8)) + 
  ylab("") +
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Robbery (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_homicide, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) +
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Homicide (x100)") + theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_burglary, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) +
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Burglary (x100)") + theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_weapons, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) +
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Weapon Crimes (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_assault, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) +
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Assault (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_rape_sexual, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) + 
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Sexual Crimes (x100)") +
 theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_theft, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) + 
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Theft (x100)") +
 theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_reckless_driving, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) + 
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Reckless Driving (x100)") +
 theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_fraud, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) +
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Fraud (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_vandalism, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) +
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Vandalism (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10)) 

sheriff_crime_grouped %>% ggplot(aes(x = year, y = mean_alcohol, color = `Presence of Gangs`)) +
  geom_line() + theme_minimal() + theme(legend.title = element_text(size=8)) + 
  ylab("") + scale_x_continuous(breaks=seq(2005,2021,2)) + 
  custom_colors + theme_ipsum() + ggtitle("LA Sheriff - Average Cases of Alcohol Offenses (x100)") +
  theme(plot.title = element_text(size = 10, face = "bold"), axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1, size = 10))