p <-
survfit2(Surv(time, status) ~ sex, data = df_lung) %>%
ggsurvfit() +
add_censor_mark() +
add_confidence_interval() +
scale_ggsurvfit()
# using the function defaults
p + add_risktable()
# change the statistics shown and the label
p +
add_risktable(
risktable_stats = "n.risk",
stats_label = list(n.risk = "Number at Risk"),
)
p +
add_risktable(
risktable_stats = "{n.risk} ({cum.event})"
)
p +
add_risktable(
risktable_stats = c("n.risk", "cum.event"),
combine_groups = TRUE
)
Run the code above in your browser using DataLab