I'm making a Kaplan-Meier curve with four different groups. I would like to remove group from the risk table but retain the names a, b, c, and d.
library('survival')
library('survminer')
df <- data.frame(group=c('a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd'), time=c(1,2,3,4,5,6,1,2,3,4,5,6), status = c(1,1,0,1,0,1,0,1,0,1,1,0))
result <- survfit(Surv(df$time, df$status==1) ~ group, data=df)
ggsurvplot(result, risk.table=T)
I would like to remove the variable name group
from the risk table (which is encircled). I've been looking around, but haven't found an obvious answer.
(Yes I know that there's an alignment issue in the risk table where it's shifted to the right, and which can be addressed with the patchwork
library.)
Please find a solution, depending on whether you want to remove or update the names of the groups
##### Update the names (please note that it also update the top legend)
ggsurvplot(result, risk.table=T, legend.labs=c("a", "b", "c", "d"))
##### Remove the names (please note that it doesn't affect the legend)
ggsurvplot(result, risk.table=T, tables.y.text=FALSE)