Visualises the distribution of length of stay (LOS) on a log10 x-axis using
either a stacked ridge plot (mode = "all") or a single-centre density
curve (mode = "single").
Usage
plot_los_ridge(
data,
mode = c("all", "single"),
center = NULL,
patient_col = "patient_id",
center_col = "center_name",
admission_col = "admission_date",
discharge_col = "final_outcome_date",
filter_outcome = NULL,
outcome_col = "final_outcome",
min_los = 1,
max_los = 365,
colours = NULL,
scale = 1.2,
alpha = 0.7,
base_size = 14,
title = NULL,
syndrome_col = NULL,
syndrome_name = NULL
)Arguments
- data
A data frame.
- mode
Character. One of
"all"(ridge plot, all centres stacked on y-axis, ordered by median LOS ascending) or"single"(density curve for one centre specified bycenter).- center
Character. Centre name required when
mode = "single".- patient_col
Character. Column of patient identifiers.
- center_col
Character. Column of centre identifiers.
- admission_col
Character. Column containing admission date/datetime. Default
"admission_date".- discharge_col
Character. Column containing discharge / final outcome date. Default
"final_outcome_date".- filter_outcome
Character or
NULL. If notNULL, only rows whose outcome column (outcome_col) equals this value are used (e.g."Discharged"). SetNULLto include all outcomes. DefaultNULL.- outcome_col
Character. Column of patient outcomes, used only when
filter_outcomeis notNULL. Default"final_outcome".- min_los
Numeric. Minimum LOS (days) to include. Rows below this are removed (prevents
log(0)issues). Default1.- max_los
Numeric. Maximum LOS (days) to include. Default
365.- colours
Named character vector of colours for centres. If
NULL(default), the RColorBrewer "Set2" palette is used.- scale
Numeric.
scaleargument passed toggridges::geom_density_ridges(). Controls overlap between ridges. Default1.2.- alpha
Numeric. Fill transparency (0-1). Default
0.7.- base_size
Numeric. Base font size. Default
14.- title
Character or
NULL. Plot title. Auto-generated ifNULL.- syndrome_col
Character or
NULL. Column of syndrome labels for pre-filtering. DefaultNULL.- syndrome_name
Character or
NULL. Syndrome value to retain. Requiressyndrome_col. DefaultNULL.