added crash_summary_charts.R script

This commit is contained in:
Ben Varick 2024-04-03 13:21:15 -05:00
parent 1a7a2bf3f8
commit 644d591fc8
Signed by: ben
SSH key fingerprint: SHA256:758jG979jvr5HnQJl1AQ/NYTyzXRgnuoVM/yCR024sE
4 changed files with 150 additions and 17 deletions

View file

@ -1,6 +1,6 @@
library(tidyverse)
library(sf)
library(tmap)
#library(tmap)
library(leaflet)
library(RColorBrewer)
library(tidycensus)
@ -81,17 +81,17 @@ focus_columns <- c("PedestrianInjurySeverity", "CrashDate", "CrashTime", "County
focus_county <- "DANE"
## generate map with tmap ----
tmap_mode("view")
Pedestrian_Crash_Data <- TOPS_geom %>%
# filter(CNTYNAME == focus_county) %>%
select(all_of(focus_columns))
tm_basemap("Stadia.AlidadeSmooth") +
tm_shape(Pedestrian_Crash_Data) +
tm_dots("PedestrianInjurySeverity", palette = injury_severity$color, popup.vars = focus_columns)
tmap_save(file = "figures/dynamic_crash_maps/dynamic_crash_map.html")
# tmap_mode("view")
#
# Pedestrian_Crash_Data <- TOPS_geom %>%
# # filter(CNTYNAME == focus_county) %>%
# select(all_of(focus_columns))
#
# tm_basemap("Stadia.AlidadeSmooth") +
# tm_shape(Pedestrian_Crash_Data) +
# tm_dots("PedestrianInjurySeverity", palette = injury_severity$color, popup.vars = focus_columns)
#
# tmap_save(file = "figures/dynamic_crash_maps/dynamic_crash_map.html")
# generate map with leaflet ----
@ -138,7 +138,7 @@ tag.map.title <- tags$style(HTML("
"))
title <- tags$div(
tag.map.title, HTML("Pedestrian Crashes</br>2017-2023")
tag.map.title, HTML("Pedestrians & Bicyclists hit by cars</br>2017-2023")
)
tag.map.subtitle <- tags$style(HTML("
@ -156,7 +156,7 @@ tag.map.subtitle <- tags$style(HTML("
"))
subtitle <- tags$div(
tag.map.subtitle, HTML("data from UW TOPS lab - retrieved 4/2024</br>per direction of the WisDOT Bureau of Transportation Safety")
tag.map.subtitle, HTML("data from UW TOPS lab - retrieved 3/2024</br>per direction of the WisDOT Bureau of Transportation Safety")
)
leaflet() %>%
@ -193,3 +193,6 @@ leaflet() %>%
# addLegendSize(position = "bottomright", color = "black", shape = "circle", values = County_Crash_Data$value.y, group = "Counties", title = "Population of County") %>%
groupOptions(group ="Counties", zoomLevels = 1:9)