2  Packages

A short stack does most of the work in this book. ggplot2 (Wickham et al. 2026) is the foundation; everything else either builds figures on top of it or supplies the modeling output we plot. If you have not installed any of it yet, skip to Section 2.1 at the end of this chapter and come back.

library(ggplot2)
library(hvtiPlotR)        # house plots, themes, and PPT/PDF export
library(hvtiRutilities)   # data dictionaries, labels, manifests
library(gt)               # publication tables
library(patchwork)        # compose multi-panel figures

What each one is for:

You do not need all of these for any single figure. Each chapter loads what it uses in its first chunk.

2.1 Installing the stack

Install the family from GitHub. Two of these packages, ggRandomForests and TemporalHazard, are on CRAN as well, but the GitHub release comes first and CRAN follows it, so GitHub is where the whole family stays in step. hvtiR (Ehrlinger 2026c) is the small control panel for that lifecycle. Use the command that matches the state you are in:

install.packages("pak")
pak::pak("ehrlinger/hvtiR")
hvtiR::install()       # fresh machine
hvtiR::status()        # compare installed packages with GitHub main
hvtiR::update()        # install only missing or stale family members
hvtiR::doctor()        # diagnose R, pak, GitHub, and member status

On a fresh machine, run the first three lines in a fresh R session, before anything attaches a family package. install() stops rather than replacing a loaded namespace, so calling it after the library() chunk above fails with already loaded in this session. Restart R before installing or updating, then use status() to check a working installation. It compares installed versions with GitHub main and, when pak recorded the source commit, catches a new commit even when the package version did not change.

When status() marks a member stale or missing, restart R and run update(). It installs only those family members, still following the GitHub-main release order. If the setup itself is puzzling, doctor() checks the R version, pak, GitHub access, and each member’s status in one report. Avoid update.packages() for this family: it can replace a GitHub install with an older CRAN release, leaving a family member out of step. Run status() and then update() instead.

That call installs the eleven family packages, and their dependencies bring in most of the rest of the stack with them: ggplot2, patchwork, survival and ggalluvial arrive with hvtiPlotR, gtsummary and flextable with hvtiRtables, randomForestSRC and varPro with ggRandomForests. Four packages the book uses are not reachable that way, and install on their own:

pak::pak(c("gt", "kernelshap", "mlbench", "ehrlinger/ggsankey"))

Expect that second list to get shorter. It holds only what no family package depends on yet, so a package the family absorbs drops out of it. gt is the likely next one to go, as table work consolidates into hvtiRtables.

Later, to find out whether an installed package has fallen behind GitHub main:

hvtiR::status()

It prints one row per family package, installed version against what is on GitHub main. That is the check worth running before you trust a figure you rendered a while ago.

2.2 What this build used

Every figure in this book is served from a cached render, so the versions that produced it are a property of the cache rather than of your session. The table below is written by the render itself, and it is the only trustworthy record of what the current cache was built against.

Family package versions this build was rendered against.
Package Version
hvtiR 1.0.13
hvtiPlotR 2.7.13
hvtiRutilities 1.1.8
hvtiRtables 1.0.0
TemporalHazard 1.2.7
ggRandomForests 4.0.0
ggsankey 0.0.99999

If that table is older than a family release you know about, the figures are too. hvtiR::status() tells you which packages have moved since, and Section 2.1 has the re-render.