install.packages("survminer")
library(survminer)
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
#簡單的生存曲線?
p1 <- ggsurvplot(fit, data = lung,
? ? ? ? ? ? ? ? legend.title = 'Sex',
? ? ? ? ? ? ? ? legend = c(.85,.8))
##生存曲線+置信區(qū)間+風險表
p2 <- ggsurvplot(
? fit,
? data = lung,
? size = 1,? ? ? ? ? ? ? ?
? palette = c("#E7B800", "#2E9FDF"),
? conf.int = TRUE,? ? ? ? ?
? pval = TRUE,? ? ? ? ? ? ?
? risk.table = TRUE,? ? ? ?
? risk.table.col = "strata",
? legend.labs =
? ? c("Male", "Female"),? ?
? risk.table.height = 0.25,
? ggtheme = theme_bw(),
? legend.title = 'Sex',
? legend = c(.85,.8)
)
arrange_ggsurvplots(list(p1,p2),ncol = 2,nrow = 1)