Is it possible to edit the risk table labels?
I'm trying to change the risk table labels ('male', 'female') to something else.
library(tidyverse)
library(ggsurvfit)
p <-
survfit2(Surv(time, status) ~ sex, data = df_lung) %>%
ggsurvfit(linewidth = 1) +
scale_ggsurvfit() +
add_risktable(
risktable_stats = c("n.risk")) +
theme_classic() +
scale_color_manual(values = c('blue', 'magenta'),
labels = c('My label', 'My other label')) +
scale_fill_manual(values = c('blue', 'magenta'),
labels = c('My label', 'My other label'))
p
If I use scale_color_manual and scale_fill_manual, the ggplot legend shows the changed labels but the table shows the output labels. How edyting risk table inside?
It's easiest to simply change the labels in the data frame before you call
survfit2()
. But you can also add anyggplot2()
functions to theadd_risktable(theme)
argument. Examples of both below!Created on 2024-01-15 with reprex v2.0.2