rggsurvfit

Add proportion of events at specified timepoints in cumulative incidence plot, ggsurvfit::add_risktable


I am using ggsurvfit package to create a cumulative incidence plot and to it I have included a risk table which currently shows Number at risk (cumulative event) as well as survival following the example of Customized statistics from package's gallery Customized statistics

However, I would like to add the proportion of persons with events at specified timepoints e.g. at 1, 2, 4 months etc within the risk table of the cumulative incidence plot instead of the survival. How can I do this?

The code below within the risk table

library(ggsurvfit)


res <- survfit2(Surv(time, status) ~ 1, data = df_colon) %>%
  ggsurvfit(type = "risk", linewidth = 0.8) +
  add_confidence_interval() +
  add_risktable(
    risktable_stats =
      c("{n.risk} ({cum.event})",
        "{round(estimate*100)}% ({round(conf.low*100)}, {round(conf.high*100)})"),
    stats_label = c("At Risk (Cum. Events)", "Survival (95% CI)")
  ) +
  scale_ggsurvfit(x_scales = list(breaks = c(0, 2, 4, 6, 8)))

risktable


Solution

  • I don't think there is a way to do this within the add_risktable() funciton. But the ggsurvfit package does export a general function for adding anything you'd like below the survival curve called ggsurvfit_align_plots(). The help file includes an example placing a figure, but you can swap the figure out for a ggplot using geom_text() to put any statistics you'd like.

    https://www.danieldsjoberg.com/ggsurvfit/reference/ggsurvfit_align_plots.html