datapasta::df_paste(head(crime_data))
data.frame(
stringsAsFactors = FALSE,
uid = c(2970134L, 2970204L, 2970345L, 2970565L, 2970568L),
date_single = c("2020-01-01 01:05:00",
"2020-01-01 07:14:00","2020-01-01 19:00:00",
"2020-01-02 20:00:00","2020-01-02 20:00:00"),
longitude = c(-97.766551,-97.71347,
-97.771795,-97.749932,-97.803012),
latitude = c(30.368206, 30.29149, 30.477788, 30.24194, 30.463511),
census_block = c("484530017052006",
"484530004021004","484910203111022","484530014012026",
"484910204032002"),
date_start = c(NA, NA, NA, NA, NA),
date_end = c(NA, NA, NA, NA, NA),
city_name = as.factor(c("Austin",
"Austin","Austin","Austin","Austin")),
offense_code = as.factor(c("23H", "90C", "23F", "23F", "23G")),
offense_type = as.factor(c("all other larceny","disorderly conduct",
"theft from motor vehicle (except theft of motor vehicle parts or accessories)",
"theft from motor vehicle (except theft of motor vehicle parts or accessories)",
"theft of motor vehicle parts or accessories")),
offense_group = as.factor(c("larceny/theft offenses","disorderly conduct",
"larceny/theft offenses","larceny/theft offenses",
"larceny/theft offenses")),
offense_against = as.factor(c("property","society","property","property",
"property")),
location_type = as.factor(c("other",
"residence","residence","residence","hotel")),
location_category = as.factor(c("other",
"residence","residence","residence","hotel"))
)
dput (head(crime_data))
library(dplyr)
library(ggplot2)
library(lubridate)
get_crime_data(
cities = "Fort Worth",
years = 2014:2017,
type = "core",
output = "sf",
cache = FALSE
) %>%
filter(offense_group == "homicide offenses") %>%
mutate(offense_year = year(date_single)) %>%
ggplot() +
geom_sf() +
facet_wrap(vars(offense_year))