Preface

This book is available in both HTML gitbook and PDF form.

The source code in the PDF version of this report is typeset in Cascadia Code, with code ligatures enabled. A similar font, Fira Code, is used in the HTML version.

0.1 R setup

# R 4.1 key features: new pipe operator, \(x) as shortcut for function(x)
# R 4.0 key features: stringsAsFactors = FALSE by default, raw character strings r"()"
if (packageVersion('base') < '4.1.0') {
  stop('This code requires R >= 4.1.0!')
}

if(!require("pacman")) install.packages("pacman")
library(pacman)

# Ensure packages are installed but do not load them
p_install(Rcpp, force = F)
p_install(RcppArmadillo, force = F)
p_install(RcppProgress, force = F)
p_install(recommenderlab, force = F)
p_install(rrecsys, force = F)
p_install(mgcv, force = F)          # provides mgcv::gam and mgcv::predict.gam
p_install(raster, force = F)        # provides raster::clamp

# Load these packages
p_load(conflicted, magrittr, knitr, kableExtra, data.table, latex2exp, patchwork,
       tidyverse, caret, lubridate)

# For functions with identical names in different packages, ensure the
# right one is chosen
conflict_prefer('RMSE', 'caret')
conflict_prefer("first", "dplyr")