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. This R package makes it available in csv files, or in an R data frame.

The secret sauce is tidyxl with a dash of unpivotr.

Installation

devtools::install_github("nacnudus/underground")

Example

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

distinct(underground, metric) %>%
  pull(metric)


nacnudus/underground documentation built on May 18, 2019, 9:14 p.m.