
Plot Competing Risks Survival Curve (Exposure to Response or Death)
Source:R/survival_analysis.R
plot_survival_cr.RdTHIS FUNCTION WILL BE DEPRICATED IN FUTURE. Plots a cumulative incidence function from a long-format dataset using a competing risks model.
Arguments
- data
A data frame in long format with the following required columns:
- ID
Subject ID
- name
Type of event: must include `"diagnose"` for response, `"dead"` for death, and others are treated as censoring
- value
Time (in days) from exposure to event
- scale
years or days (timeline)
- colors
A character vector of color hex codes to use for the plotted event types. Default is `c("#5CB85C", "#343A40")`.
Details
Internally converts event types into status codes for competing risks analysis:
1 = diagnose (response)
2 = dead
3 = censored
Uses `cuminc()` from the `cmprsk` package and visualizes the results using `ggcompetingrisks()`. Designed to run in both interactive and Shiny environments, using `.safe_inc_progress()` for optional progress updates.