library(ggplot2)
library(tidyverse)
## ── Attaching packages ───────────────────────── tidyverse 1.2.1 ──
## ✔ tibble 2.1.3 ✔ purrr 0.3.3
## ✔ tidyr 1.0.0 ✔ dplyr 0.8.3
## ✔ readr 1.3.1 ✔ stringr 1.4.0
## ✔ tibble 2.1.3 ✔ forcats 0.4.0
## ── Conflicts ──────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(sf)
## Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
library(tmap)
arrests <- read_csv('data/aug6_12_arrest_data.csv')
## Parsed with column specification:
## cols(
## latitude = col_double(),
## longitude = col_double(),
## zipcode = col_double(),
## arr_date2 = col_date(format = ""),
## arrest_time = col_time(format = ""),
## age = col_double(),
## sex = col_character(),
## race_cat = col_character(),
## arrest_type = col_character(),
## charge = col_character()
## )
arrests_sf <- st_as_sf(arrests, coords = c("longitude", "latitude"), crs = 4326)
#geometry type: MULTIPOLYGON
la_zips <- st_read(dsn = "data/Los_Angeles_City_Zip_Codes/Los_Angeles_City_Zip_Codes.shp")
## Reading layer `Los_Angeles_City_Zip_Codes' from data source `/Users/timdennis/instruction/afam188/2019-11-18-afam188/data/Los_Angeles_City_Zip_Codes/Los_Angeles_City_Zip_Codes.shp' using driver `ESRI Shapefile'
## Simple feature collection with 157 features and 7 fields
## geometry type: MULTIPOLYGON
## dimension: XY
## bbox: xmin: -118.6682 ymin: 33.70491 xmax: -118.1554 ymax: 34.33731
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
tmap_mode("view")
## tmap mode set to interactive viewing
tm <- tm_shape(la_zips) +
tm_polygons() +
tm_shape(arrests_sf) +
tm_dots()
tm
## Warning: The shape la_zips is invalid. See sf::st_is_valid