First, let’s look at the summary of the file scpullovers. We are wanting to look at the total number of stops made in each area.

## Observations: 249,874
## Variables: 11
## $ id                <chr> "SC-2005-000044", "SC-2005-000343", "SC-2005...
## $ stop_date         <chr> "1/1/05", "1/1/05", "1/1/05", "1/1/05", "1/1...
## $ county_name       <chr> "Aiken County", NA, "Lexington County", "Aik...
## $ county_fips       <int> 45003, NA, 45063, 45003, 45047, 45063, 45047...
## $ police_department <chr> "SCHP", "SCHP", "SCHP", "SCHP", "SCHP", "SCH...
## $ driver_gender     <chr> "F", "M", "F", "F", "F", "M", "M", "M", "M",...
## $ driver_age        <int> 23, 29, 23, 40, 74, 41, 25, 46, 23, 30, 24, ...
## $ driver_race       <chr> "White", "Black", "White", "White", "White",...
## $ lat               <dbl> 33.67878, 34.33084, 34.02148, 33.79552, 34.2...
## $ lon               <dbl> -81.63705, -79.18744, -81.13352, -81.47273, ...
## $ officer_race      <chr> "White", "White", "White", "White", "White",...

Note, this is the data frame that was used after filtering out all the missing data from the latitude and longitude columns with the formula below.

Tigris and API

As a disclaimer: Unfortunately, because of missing longitude and latitude data, nearly half of the data will be missing in the end of this study. However, it is crucial for the longitude and latitude to be present for our data to work. In the future, it is urged for future stops or past stops to be geolocated in hopes to improve future studies.

Shapefiles

Originally, a shapefile was created for charleston, which was done with our census API key. We need a spatial anlaysis to transform our coordinates into a correct shapefile to further combine them to the charleston shapefile.

After that has loaded, we need to combine the shapefiles of charleston and scpullovers_spatial to provide us with a GEOID.

Finally, we will create a new dataframe to summarize the totals of pullovers done by each grouped GEOID. We can then start our mapping process!

# Summary of total in each area by grouping by GEOID
by_tract <- points_in %>%
  group_by(GEOID) %>%
  summarise(total=n())

# View by_tract
head(by_tract)
## Simple feature collection with 6 features and 2 fields
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: -79.96102 ymin: 32.76303 xmax: -79.92364 ymax: 32.79532
## epsg (SRID):    4269
## proj4string:    +proj=longlat +datum=NAD83 +no_defs
## # A tibble: 6 x 3
##   GEOID     total                                                 geometry
##   <chr>     <int>                                            <POLYGON [°]>
## 1 45019000…     1 ((-79.94435 32.77618, -79.94479 32.77698, -79.94108 32.…
## 2 45019000…     1 ((-79.93538 32.77073, -79.93382 32.77201, -79.93424 32.…
## 3 45019000…     1 ((-79.94096 32.78438, -79.93938 32.78471, -79.93771 32.…
## 4 45019000…     1 ((-79.95556 32.78058, -79.94692 32.78289, -79.94557 32.…
## 5 45019000…     1 ((-79.96102 32.7835, -79.95656 32.7853, -79.95096 32.78…
## 6 45019000…     1 ((-79.9437 32.79192, -79.94183 32.79379, -79.93861 32.7…

ggplot of North Charleston Police Pullovers

We see that North Charleston has several dense areas where police has pulled individuals over. The highlighted area we see outlined in black is North Charleston.