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. - ggraph (Pedersen 2025a): draws the one dependency graph in the book, the unsupervised variable network in the VarPro chapter. It is a
SuggestsofggRandomForestsrather than an import, so installing the family does not bring it along andplot(gg_udependent(...))stops to ask for it. - patchwork (Pedersen 2025b): 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
SynthDiabetesset for a classification forest that discriminates well enough to draw a ROC curve worth reading. It loads only in that chapter. Version 2.1-11 or newer, which is where that synthetic set replaced the withdrawn Pima Indians data. On an oldermlbenchthe chapter stops atobject not found. - broom (Robinson et al. 2026): no chapter calls it, but
gtsummary’s comparison tests do. Without it the p-value column of acompare = "pvalue"table comes back blank, with only a warning to say why, andhv_test_footnotes_jtcvs()then has no tests to footnote. - ggsci (Xiao 2026): colour scales drawn from the figures of particular journals (NEJM, Lancet, JAMA, BMJ and others). It loads only in the colour chapter, for the journal palettes recipe.
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 twelve 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. Seven packages the book uses are not reachable that way, and install on their own:
pak::pak(c("gt", "ggraph", "kernelshap", "mlbench", "ggsci", "broom",
"davidsjoberg/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. It records the family and five CRAN packages. Four have changed this book’s output before: randomForestSRC (the forests every forest chapter grows), varPro (variable priority), mlbench (the SynthDiabetes data behind the ROC recipe) and consort (the layout of the CONSORT diagram, which moved in 1.2.4). The fifth, ggsci, has not, but its palettes are hex codes the colour chapter prints directly, so a release that retunes one changes those figures with nothing else to show for it. Anything else the render loads is not tracked here.
| Package | Version | Commit | Source |
|---|---|---|---|
| hvtiR | 1.2.8 | e92d18d | family |
| hvtiPlotR | 2.8.10 | 6f50cde | family |
| hvtiRutilities | 1.5.4 | 55ae34c | family |
| hvtiRtables | 1.0.5 | 6d1aa14 | family |
| TemporalHazard | 1.2.16 | 746ce9e | family |
| ggRandomForests | 4.0.0 | 99acd37 | family |
| ggsankey | 0.0.99999 | b675d0d | family |
| randomForestSRC | 3.9.0 | CRAN | |
| varPro | 3.3.0 | CRAN | |
| mlbench | 2.1-11 | CRAN | |
| consort | 1.2.4 | CRAN | |
| ggsci | 5.2.0 | CRAN |
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.