Generates a standard Kaplan-Meier plot using ggplot2 and survival.
Usage
create_km_plot(
data,
time_var = "AVAL",
event_var = "CNSR",
trt_var = "TRT01P",
title = "Kaplan-Meier Plot",
xlab = "Time",
ylab = "Survival Probability",
risk_table = FALSE,
show_median = FALSE,
show_ci = FALSE,
show_censor = TRUE,
landmarks = NULL,
xlim = NULL,
palette = NULL,
conf_level = 0.95
)Arguments
- data
ADaMData object or data frame containing survival data
- time_var
Time variable name (default: "AVAL")
- event_var
Event variable name. If "CNSR" (ADaM censoring flag), it will be automatically inverted (0=event becomes 1=event). Otherwise expects 1=event, 0=censor. Default: "CNSR"
- trt_var
Treatment variable name (default: "TRT01P")
- title
Plot title
- xlab
X-axis label
- ylab
Y-axis label
- risk_table
Logical, include risk table below. Requires patchwork.
- show_median
Logical, add horizontal/vertical lines at median survival time (default: FALSE)
- show_ci
Logical, show confidence bands around survival curves (default: FALSE)
- show_censor
Logical, show censoring marks as crosses (default: TRUE)
- landmarks
Numeric vector of timepoints to highlight with vertical lines (e.g., c(12, 24) for 12 and 24 months). NULL for none.
- xlim
Optional x-axis limits as c(min, max)
- palette
Optional color palette for treatment groups. If NULL, uses default ggplot2 colors.
- conf_level
Confidence level for CI bands (default: 0.95)