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 figures2 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.
What each one is for:
- hvtiR (Ehrlinger 2026c): the family installer and health check. It puts the related packages on the same GitHub-main release path, tells you whether an installed member has moved, updates only the members that need it, and diagnoses an R or GitHub setup that cannot get that far.
- hvtiPlotR (Ehrlinger 2026b): the core of the book. It wraps the figures we publish into a two-step API: an
hv_*()constructor validates the data and returns an object, andplot()turns that object into a bare ggplot. It also carries the house themes (theme_hv_manuscript(),theme_hv_poster(), the PowerPoint themes) and the save helpers. - hvtiRutilities (Ehrlinger 2026e): the data-governance side: data dictionaries, variable labels, dataset manifests, and the synthetic-data generators we use so the examples run without touching real patient data.
- ggRandomForests (Ehrlinger 2026a), randomForestSRC (Ishwaran and Kogalur 2026; Ishwaran and Kogalur 2007; Ishwaran et al. 2008), and varPro (Lu et al. 2026): the random-forest stack.
randomForestSRCfits the forest,varProdoes variable selection, andggRandomForeststurns either one into a ggplot. These load in the random forest chapters where they are used. - TemporalHazard (Ehrlinger 2026f): our R port of the SAS/C HAZARD module, for parametric and nonparametric hazard modeling. It loads in its own chapter.
- gt (Iannone et al. 2026): publication-quality tables, and the right choice when the table’s destination is this book or another HTML document.
- hvtiRtables (Ehrlinger 2026d): manuscript tables. It takes a
gtsummarysummary and renders it throughflextableinto a Word table that follows the CORR “Table Construction for Manuscripts” rules: flat headers with nothing merged, no hidden spacer columns, and footnotes and the abbreviation key as text below the table. A JTCVS mode swaps in that journal’s merged spanning headers and lettered footnotes instead. - gtsummary (Sjoberg et al. 2026) and flextable (Gohel and Skintzos 2026): the two packages
hvtiRtablesis built on.gtsummary::tbl_summary()computes the baseline summary andflextableis the Word rendering layer. You call the first one directly in the manuscript tables chapter; the second mostly stays under the hood. - kernelshap (Mayer and Watson 2025): the SHAP engine behind
gg_shap(). It loads in the SHAP attribution chapter, and it is the one dependency in the book whose cost you feel, so that chapter says what the two size arguments buy you. - patchwork (Pedersen 2025): composes several plots into one figure with shared labels and panel tags.
- survival (Therneau 2026; Terry M. Therneau and Patricia M. Grambsch 2000): the
Surv()objects and Kaplan-Meier machinery underneath the survival figures. - mlbench (Leisch and Dimitriadou 2026): example data only: the ROC chapter borrows its Pima Indians diabetes set for a classification forest that discriminates well enough to draw a ROC curve worth reading. Loaded just in that chapter.
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 statusOn 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.
| 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.