Is there a concise way to remove the variable name in the legend of plots created by ggsurvplot
?
Example:
library(survival)
library(survminer)
set.seed(123)
df=data.frame(gender=c(rep("male", 10), rep("female", 10)), value=c(rnorm(10,mean = 2), rnorm(10,mean = 3)))
fit = surv_fit(Surv(value) ~ gender, data = df)
p = ggsurvplot(fit, data = df, surv.median.line = "none")
What I want is to remove the word 'gender' from the legend as in the following plot. I can achieve this by manually setting the legend labels:
p = ggsurvplot(fit, data = df, surv.median.line = "none", legend.labs = c("male", "female"))
But is there a better way?
EDIT: I accidentally swapped male and female when I manually assigned the gender (2. plot), which shows how dangerous this method is.