I have two types of events in this dataset that I am trying to plot on a cumulative incidence plot.
data(Melanoma, package = "MASS")
Melanoma <- Melanoma %>%mutate(
status = as.factor(recode(status, `2` = 0, `1` = 1, `3` = 2)))
###status 0=alive, 1=died from melanoma, 2=dead from other causes
cuminc(Surv(time, status) ~ 1, data = Melanoma) %>%
ggcuminc(outcome = c("1", "2")) +
labs(
x = "Days") +
add_confidence_interval() +
add_risktable()
The risk table shows two rows: at risk and events.
What I need is to have a risk table showing the breakdown of each events. For example, it should have three rows, one indicating people at risk, another with events 1, and next with events 2.
I haven't found any potential way to solve this.
There is no native way to do this in ggsurvfit. But the package exports utilities that make it possible. Example below.
Created on 2023-11-01 with reprex v2.0.2