4.3 Chicago Train Ridership dataset

library(tidyverse)
library(lubridate)
## Loading required package: timechange
library(plotly)
library(patchwork)
library(here)
## here() starts at /home/runner/work/bookclub-feat_eng/bookclub-feat_eng
library(heatmaply)
## Loading required package: viridis
## Loading required package: viridisLite
## 
## Attaching package: 'viridis'
## The following object is masked from 'package:scales':
## 
##     viridis_pal
## 
## ======================
## Welcome to heatmaply version 1.4.0
## 
## Type citation('heatmaply') for how to cite the package.
## Type ?heatmaply for the main documentation.
## 
## The github page is: https://github.com/talgalili/heatmaply/
## Please submit your suggestions and bug-reports at: https://github.com/talgalili/heatmaply/issues
## You may ask questions at stackoverflow, use the r and heatmaply tags: 
##   https://stackoverflow.com/questions/tagged/heatmaply
## ======================
library(RColorBrewer)
library(skimr)
library(vcd)
## Loading required package: grid
library(colorspace)
library(FactoMineR)
library(caret)
load(url("https://github.com/topepo/FES/blob/master/Data_Sets/Chicago_trains/chicago.RData?raw=true"))
load(url("https://github.com/topepo/FES/blob/master/Data_Sets/Chicago_trains/stations.RData?raw=true"))

Create train_plot_data

train_plot_data <- 
     training %>% 
     mutate(date = train_days) %>% 
     relocate(date, .before = everything())
train_plot_data
## # A tibble: 5,698 × 1,092
##    date       s_40380 dow     doy  week month  year Advent1st Advent2nd Advent…¹
##    <date>       <dbl> <fct> <dbl> <dbl> <fct> <dbl>     <dbl>     <dbl>    <dbl>
##  1 2001-01-22   15.7  Mon      22     4 Jan    2001         0         0        0
##  2 2001-01-23   15.8  Tue      23     4 Jan    2001         0         0        0
##  3 2001-01-24   15.9  Wed      24     4 Jan    2001         0         0        0
##  4 2001-01-25   15.9  Thu      25     4 Jan    2001         0         0        0
##  5 2001-01-26   15.4  Fri      26     4 Jan    2001         0         0        0
##  6 2001-01-27    2.42 Sat      27     4 Jan    2001         0         0        0
##  7 2001-01-28    1.47 Sun      28     4 Jan    2001         0         0        0
##  8 2001-01-29   15.5  Mon      29     5 Jan    2001         0         0        0
##  9 2001-01-30   15.9  Tue      30     5 Jan    2001         0         0        0
## 10 2001-01-31   15.9  Wed      31     5 Jan    2001         0         0        0
## # … with 5,688 more rows, 1,082 more variables: Advent4th <dbl>,
## #   AllSaints <dbl>, AllSouls <dbl>, Annunciation <dbl>, Ascension <dbl>,
## #   AshWednesday <dbl>, AssumptionOfMary <dbl>, BirthOfVirginMary <dbl>,
## #   BoxingDay <dbl>, CaRemembranceDay <dbl>, CelebrationOfHolyCross <dbl>,
## #   ChristmasEve <dbl>, ChristTheKing <dbl>, CorpusChristi <dbl>, Easter <dbl>,
## #   EasterMonday <dbl>, EasterSunday <dbl>, Epiphany <dbl>,
## #   MassOfArchangels <dbl>, PalmSunday <dbl>, Pentecost <dbl>, …