Created
February 5, 2019 17:29
-
-
Save ryanrosenberg/7ea42fed29c4fd99aaabdf817402768c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(sf) | |
library(lubridate) | |
chicago_neighborhoods <- read_sf("chi_community_shapefiles") %>% | |
mutate(community_area = as.integer(area_numbe)) | |
chicago_potholes <- read_csv("chicago_potholes.csv") %>% | |
janitor::clean_names() %>% | |
mutate_at(vars(creation_date, completion_date), mdy) %>% | |
mutate(time_to_fill = difftime(completion_date, creation_date)) | |
completed_potholes <- chicago_potholes %>% | |
filter(status == "Completed") | |
pothole_map <- completed_potholes %>% | |
left_join(chicago_neighborhoods) %>% | |
filter(!is.na(community)) %>% | |
group_by(community) %>% | |
summarize(median_time_to_fill = as.numeric(median(time_to_fill), | |
units = "days")) | |
chicago_neighborhoods %>% | |
left_join(pothole_map) %>% | |
ggplot() + | |
geom_sf(aes(fill = median_time_to_fill), color = "#555555") + | |
guides(fill = guide_colorbar(title = "Median Days to\nFill Pothole")) + | |
labs(title = "Chicago Neighborhoods by Time to Fill Pothole", | |
caption = "311 Service Request Data from the Chicago Data Portal\nRestricted to completed service requests, 2011 - 2018") + | |
scale_fill_viridis_c(option = 'B') + | |
theme_void() + | |
theme(panel.grid.major = element_line(colour = 'transparent'), | |
text = element_text(family = "Lato", size = 16)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment