unknown column exploring crimedata

Hi all,
I am trying to use the package crimedata for a class. When I run this code, which is from Michael Ashby's article on using crimedata I get unknown columns "location_types"

get_crime_data(
  cities = "Fort Worth", 
  years = 2014:2017, 
  type = "core",
  output = "sf"
) %>% 
  filter(offense_group == "homicide offenses") %>% 
  mutate(offense_year = year(date_single)) %>% 
  ggplot() + 
  geom_sf() +
  facet_wrap(vars(offense_year))

I know the column is there because when I call names() it's listed.

Has anyone run into this or knows how to address it?

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

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))

Its a warning from inside the crimedata package. your code appears to run fine regardless.
My suggestion would be to ignore the warning.

Thank you so much for the quick response. I'm using it for a class and wanted to be sure there wasn't some issue that could crop up later on.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.