R语言 KM曲线作图及logrank检验

高低危分两组

library("survival")
library("survminer")
 # best cutoff
     res.cut <- surv_cutpoint(RC_N, time = "time", event = "event", variables = c("value"))
     res.cat <- surv_categorize(res.cut)
     
     fit <- survfit(Surv(time, event) ~ value, data = res.cat)
     
     ggsurvplot(fit,  main = "Survival curve"
                , data = res.cat
                , risk.table = F
                , conf.int = F # confident internal
                , pval = T
                , pval.method = F
                , surv.median.line = "hv" # median survival line
                , title="* prognostic prediction"
                , legend.title = "* prediction"  
                , legend.labs=c("high risk","low risk")
                , font.main = c(16, "bold", "darkblue")
                , font.x = c(14, "bold", "black")
                , font.y = c(14, "bold", "black")
                , font.tickslab = c(12, "plain", "black") # legend color
                , palette = c("lancet")  #change color to blue and yellow:c("#E7B800", "#2E9FDF") = c("jco"), or c("lancet")
                , ggtheme = theme_bw() # grid in table
     ) 
     # log-rank检验
     surv_diff <- survdiff(Surv(time, event) ~ value, data = res.cat)
     print(surv_diff)
     ```

你可能感兴趣的:(生存分析)