library(survival)
library(ranger)
library(ggplot2)
library(dplyr)
library(ggfortify)
data(veteran)
km_fit <- survfit(Surv(time, status) ~ trt, data=veteran)
autoplot(km_fit)
km_fit <- survfit(Surv(time, status) ~ trt + age, data=veteran)
autoplot(km_fit)
如何获得调整后的KM曲线?在此示例中,当我在survfit模型中添加“年龄”时,会出现以下错误:
levels<-
(*tmp*
中的错误,value = as.character(levels)):
因子级别[31]已重复
那么您如何估算调整后的KM曲线并绘制它们呢?