https://github.com/nacnudus/underground
An R package to distribute London Underground performance data in a convenient form
https://github.com/nacnudus/underground
Last synced: 2 months ago
JSON representation
An R package to distribute London Underground performance data in a convenient form
- Host: GitHub
- URL: https://github.com/nacnudus/underground
- Owner: nacnudus
- License: other
- Created: 2017-11-25T15:14:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-18T06:30:33.000Z (over 6 years ago)
- Last Synced: 2025-01-05T18:26:55.516Z (4 months ago)
- Language: R
- Homepage: https://nacnudus.github.io/underground/
- Size: 24.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# underground
**Updated on `r Sys.Date()` with data up to 2018-08-18**
London Underground performance data is published in
[spreadsheets](https://tfl.gov.uk/corporate/publications-and-reports/underground-services-performance).
This R package makes it available in [csv
files](https://github.com/nacnudus/underground/tree/master/inst/extdata), or in
an R data frame.The secret sauce is [tidyxl](https://nacnudus.github.io/tidyxl) with a dash of
[unpivotr](https://nacnudus.github.io/unpivotr).## Installation
```r
devtools::install_github("nacnudus/underground")
```## Example
```{r}
library(underground)
library(dplyr)
library(ggplot2)underground %>%
filter(metric == "Train delays longer than 15 minutes",
year == "2018/19",
is.na(quarter),
period == 5,
line != "All Lines") %>%
mutate(fill= underground_colours[line]) %>%
select(line, value, fill) %>%
ggplot(aes(line, value, fill = fill)) +
geom_bar(stat = "identity") +
scale_fill_identity("", labels = underground_lines, guide = "legend") +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
xlab("") +
ylab("") +
ggtitle("Train delays longer than 15 minutes",
subtitle = "Period 5 2018/19 from 21 July to 17 August 2018")
```## Control periods
Most series are reported in 'periods' approximately four weeks long, used by the
whole UK rail industry. Some periods are shorter or longer so that each year is
covered by exactly 13 periods, beginning on the April the 1st.Join the dataset `rail_periods` to resolve periods (1 to 13) to dates.
## Metrics
```{r}
distinct(underground, metric) %>%
pull(metric)
```