Preface

This template generates output in both HTML and PDF form. Code chunks are typeset in Fira Code, with code ligatures enabled.

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!')
}

# Package manager
if(!require("pacman")) install.packages("pacman")

# Keras - deep learning package.  You may need to restart R after installation
# before proceeding with the rest of the code in this project.
if(!require("keras")) {
  install.packages("keras")
  keras::install_keras()
}

library(pacman)
p_load(data.table, dtplyr, tidyverse, R.utils, Rfast, knitr,
       keras, caret, pROC, knitr, conflicted)

# The `conflicted` package will throw an error if a function name is ambiguous, unless
# A preferred package is given below.
conflict_prefer('summarize', 'dplyr')
conflict_prefer('summarise', 'dplyr')
conflict_prefer('filter', 'dplyr')
conflict_prefer('between', 'dplyr')
conflict_prefer('auc', 'pROC')

# Somehow, this seems to prevent memory leaks
tensorflow::tf$compat$v1$disable_eager_execution()