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.
Arguments
- tracker
An
hv_consort_trackerwith at least two stages (callhv_consort_exclude()at least once afterhv_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(). Default0.9.- width
Diagram width in inches. Defaults to
7.- height
Diagram height in inches. Defaults to
2 + n_stages * 1.2, wheren_stagesis the number of stages in the tracker.- ...
Additional arguments forwarded to
consort::consort_plot().
Value
An hv_consort object – a list with:
$plotThe grid object returned by
consort::consort_plot().$metaNamed list:
n_stages,width,height,orders,side_box.$trackerThe 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{}