Skip to contents

Reads the stage metadata stored in an hv_consort_tracker, auto-derives the orders and side_box arguments for consort::consort_plot(), and returns an hv_consort object wrapping the grid diagram.

Usage

hv_consort(
  tracker,
  side_box = "all",
  cex = 0.9,
  width = NULL,
  height = NULL,
  ...
)

Arguments

tracker

An hv_consort_tracker with at least two stages (call hv_consort_exclude() at least once after hv_consort_start()).

side_box

Character vector of exclusion-reason column names to display as side boxes, or "all" (default) to include every exclusion column.

cex

Numeric; text size scaling passed to consort::consort_plot(). Default 0.9.

width

Diagram width in inches. Defaults to 7.

height

Diagram height in inches. Defaults to 2 + n_stages * 1.2, where n_stages is the number of stages in the tracker.

...

Additional arguments forwarded to consort::consort_plot().

Value

An hv_consort object – a list with:

$plot

The grid object returned by consort::consort_plot().

$meta

Named list: n_stages, width, height, orders, side_box.

$tracker

The original hv_consort_tracker.

Examples

cohort <- data.frame(
  mrn  = paste0("P", 1:100),
  age  = sample(15:80, 100, TRUE),
  echo = sample(c(TRUE, FALSE), 100, TRUE, prob = c(0.9, 0.1))
)
tracker <- hv_consort_start(cohort, patient_id = mrn) |>
  hv_consort_exclude(label = "Eligible", col = "excl_screen",
                      age < 18 ~ "Age < 18") |>
  hv_consort_exclude(label = "Analyzed", col = "excl_eligible",
                      !echo ~ "Missing echocardiogram")
fig <- hv_consort(tracker)
if (FALSE) plot(fig) # \dontrun{}