这个错误可能是因为缺少 'xfun' 包导致的。我们可以通过安装 'xfun' 包来解决这个问题:

install.packages('xfun')

然后再次运行代码即可。

示例代码:

time <- c(6,6,6,7,10,13,16,22,23,6,9,10,11,17,19,20,25,32,32,34,35,1,1,2,2,3,4,4,5,5,8,8,8,8,11,11,12,12,15,17,22,23)
status <- c(rep(1,21),rep(0,21))
treat <- c(rep('6-MP',21),rep('Placebo',21))
data <- data.frame(time, status, treat)

# 计算生存函数的乘积限估计
fit <- survfit(Surv(time, status) ~ treat, data = data)

ggsurvplot(fit, data = data, pval = TRUE, legend.title = 'Treatment',
            risk.table = TRUE, risk.table.col = 'strata', ggtheme = theme_minimal())
R语言:解决 'xfun' 包错误并使用 ggsurvplot 绘制生存曲线

原文地址: https://www.cveoy.top/t/topic/n6yq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录