generated from itsleeds/RpackageTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
87 lines (60 loc) · 3.09 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
<!-- [![Travis build status](https://travis-ci.org/ITSLeeds/trafficalmr.svg?branch=master)](https://travis-ci.org/ITSLeeds/trafficalmr) -->
<!-- [![Coverage status](https://codecov.io/gh/ITSLeeds/trafficalmr/branch/master/graph/badge.svg)](https://codecov.io/github/ITSLeeds/trafficalmr?branch=master) -->
<!-- [![Build status](https://ci.appveyor.com/api/projects/status/gqp3smc04as3qg85?svg=true)](https://ci.appveyor.com/project/layik/trafficalmr-05ana) -->
[![R build status](https://github.com/saferactive/trafficalmr/workflows/R-CMD-check/badge.svg)](https://github.com/saferactive/trafficalmr/actions)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Codecov test coverage](https://codecov.io/gh/saferactive/trafficalmr/branch/master/graph/badge.svg)](https://codecov.io/gh/saferactive/trafficalmr?branch=master)
# trafficalmr
This is an R package to support road safety and traffic calming measures.
# Installation
```{r, eval=FALSE}
remotes::install_github("saferactive/trafficalmr")
```
```{r}
library(trafficalmr)
```
# Get traffic calming data
```{r, eval=FALSE}
traffic_calming_points = tc_get_osm(bbox = "chapeltown leeds")
```
```{r, echo=FALSE, eval=FALSE}
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")
```
```{r, echo=FALSE, eval=FALSE}
u = "https://github.com/saferactive/trafficalmr/releases/download/0.0.1/traffic_calming_points_chapeltown.Rds"
traffic_calming_points = readRDS(url(u))
```
```{r, eval=FALSE}
mapview::mapview(traffic_calming_points["traffic_calming"])
```
![](https://user-images.githubusercontent.com/1825120/87041987-f2e7b180-c1ea-11ea-9731-b2b9512fd0ea.png)
# Recoding data
Recode vehicle types:
```{r}
tc_recode_vehicle_type(c("Bus long", "Motorcycle long name"))
```
This can be useful in visualisation:
```{r, fig.show='hold', fig.width=8, out.width="50%"}
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()`](https://saferactive.github.io/trafficalmr/reference/tc_recode.html) for details.
# Development (contributing)
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.