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.



Checking the Melanome data.frame and the parameters of ggcuminc function, I understand that you want to visualizate the cumulative incidence of events 1=died from melanoma and 2=dead from other causes
Therefore, it does not make sense to keep the patients assigned status=0. It is not possible to know the cause of death for these patients.
All patients show an event (died from melanoma or dead from other causes) so status is fixed to 1. There is not censor elements althought a level must be defined in status.
Cumulative incidence is plotted with the risk tables (at risk and events) for the two events (1 and 2)