French Train Delays

Heat map

Published

February 25, 2019

Notable topics: Heat map

Recorded on: 2019-02-25

Timestamps by: Alex Cookson

View code

Screencast

Timestamps

fct_lump

Boxplots of departure stations using fct_lump function

Creating heat map of departure and arrival delays, then cleaning up a sparse heat map

fct_reorderlength

Using fct_reorder function and length function to reorder stations based on how frequently they appear

fct_infreq

Using fct_infreq to reorder based on infrequently-appearing stations (same as above, but without a trick needed)

fct_lump

Using fct_lump function to lump based on proportion instead of number of top categories desired

scale_fill_gradient2

Using scale_fill_gradient2 function to specify diverging colour scale

Checking another person's take on the data, which is a heatmap over time

sprintf

Converting year and month (as digits) into date-class variable using sprintf function and padding month number with extra zero when necessary

summarise_at

Using summarise_at function to quickly sum multiple columns

geom_tile

Creating heatmap using geom_tile function for percentage of late trains by station over time

fill

Using fill function to fill in missing NA values with data from previous observations

paste0

Grouping multiple variables into a single category using paste0 function

Grouping heatmap into International / National chunks with a weird hack

Further separating International / National visually

Less hacky way of separating International / National (compared to previous two rows)