This interactive map shows the number and locations of fatal motor vehicle crashes on Victorian roads in 2018.
Zoom in and click on individual markers to identify the date, speed limit, light conditions, type of crash, and number of fatalities for each crash.
# load data
crashdata <- read.csv("crashdata.csv")
# Load leaflet package
library(leaflet)
# Load background map
my_map <- leaflet() %>%
addTiles
# Add lat long markers
my_map <- my_map %>%
addMarkers(lat = crashdata$Latitude, lng = crashdata$Longitude,
popup = paste(crashdata$ï..Date,',', 'Speed limit', crashdata$Speed_zone, 'km/h,',
crashdata$Light_conditions,',', crashdata$Crash_type,',',
crashdata$Number_killed, 'killed'),
clusterOptions = markerClusterOptions())
# Run map
my_map
sessionInfo()
## R version 3.5.3 (2019-03-11)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 17763)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_United States.1252
## [2] LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] leaflet_2.0.2
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.1 later_0.8.0 digest_0.6.18 mime_0.6
## [5] R6_2.4.0 jsonlite_1.6 xtable_1.8-4 magrittr_1.5
## [9] evaluate_0.13 stringi_1.4.3 promises_1.0.1 rmarkdown_1.12
## [13] tools_3.5.3 stringr_1.4.0 htmlwidgets_1.3 crosstalk_1.0.0
## [17] shiny_1.3.2 httpuv_1.5.1 xfun_0.7 yaml_2.2.0
## [21] compiler_3.5.3 htmltools_0.3.6 knitr_1.23