knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This is an R package to support road safety and traffic calming measures.
remotes::install_github("saferactive/trafficalmr")
library(trafficalmr)
traffic_calming_points = tc_get_osm(bbox = "chapeltown leeds")
saveRDS(traffic_calming_points, "traffic_calming_points_chapeltown.Rds") piggyback::pb_upload("traffic_calming_points_chapeltown.Rds") piggyback::pb_download_url("traffic_calming_points_chapeltown.Rds")
u = "https://github.com/saferactive/trafficalmr/releases/download/0.0.1/traffic_calming_points_chapeltown.Rds" traffic_calming_points = readRDS(url(u))
mapview::mapview(traffic_calming_points["traffic_calming"])
Recode vehicle types:
tc_recode_vehicle_type(c("Bus long", "Motorcycle long name"))
This can be useful in visualisation:
v = stats19::get_stats19(year = 2018, type = "vehicles") v$vehicle_type_simple = tc_recode_vehicle_type(v$vehicle_type) barplot(table(v$vehicle_type)) barplot(table(v$vehicle_type_simple))
Note that the second plot on the right is much easier to interpret.
See ?tc_recode()
for details.
R package testthat
is used to test this package. Some of the tests, understandably, need to make calls to OSM and other remote services. The package has an ENV to avoid running network calls (downloads). If you like to avoid running them set an ENV var with DONT_DOWNLOAD_ANYTHING = false
so that you skip them. If curl::has_internet()
fails, they will be skipped anyways.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.