I'm performing a survival analysis. I want to plot two cumulative incidence functions on the same graph, one based on age groups (Edad60 variable) and the other on all the patients. I don't know how to combine them.
Here's the code in R:
#install.packages("ggsurvfit")
library(ggsurvfit)
#install.packages("tidycmprsk")
library(tidycmprsk)
AML_RC$Cuminc <- factor(AML_RC$Cuminc,
levels = c(0,1,2),
labels = c("Censor", "Relapse", "Non-Relapse Mortality"))
# By age groups:
cuminc(Surv(SLEmonths, Cuminc) ~ Edad60, data = AML_RC) %>%
ggcuminc(outcome = c( "Relapse", "Non-Relapse Mortality")) +
labs(x = "Months after diagnosis") +
scale_x_continuous(breaks = seq(0, max(AML_RC$SLEmonths), by = 20)) +
scale_y_continuous(limits = c(0, 1)) +
theme_classic() +theme(legend.position = 'bottom', legend.direction = "horizontal") +
scale_color_manual(values = c("1" = "salmon2", "2" = "deepskyblue3"),
labels = c("1" = "18-60 y.o.", "2" = "61-70 y.o."))
# All patients:
cuminc(Surv(SLEmonths, Cuminc) ~ 1, data = AML_RC) %>%
ggcuminc(outcome = c( "Relapse", "Non-Relapse Mortality")) +
labs(x = "Months after diagnosis") +
scale_x_continuous(breaks = seq(0, max(AML_RC$SLEmonths), by = 20)) +
scale_y_continuous(limits = c(0, 1)) +
theme_classic() +theme(legend.position = 'bottom', legend.direction = "horizontal"))
Does anyone know how to do this? In the case of survival curves, there's the function ggsurvplot_combine. I imagine there must be something similar for cumulative incidences.
Thank you and happy Women's Day!:)