我正在尝试遵循生存分析的教科书示例,但不确定我在哪里出错:
df1 <- as.data.frame( cbind(seq(1:5),c(6,44,21,14,62),c(1,1,0,1,1)) )
names(df1) <- c('subject','time','censor')
require(survival)
f1 <- survfit(Surv(time=time, event=censor) ~1, data=df1)
quantile(f1)
这给出了以下内容:
Error in xi == xj : comparison of these types is not implemented
In addition: Warning messages:
1: In `[.survfit`(x, !nas) :Survfit object has only a single survival curve
2: In `[.survfit`(x, i) : Survfit object has only a single survival curve
3: In `[.survfit`(x, j) : Survfit object has only a single survival curve
我已经用不止一条曲线的 survfit 对象尝试过这个,但仍然得到相同的消息......
“R 版本 2.14.1 (2011-12-22)”
“x86_64-pc-linux-gnu”
搜索()的输出:
[1] ".GlobalEnv" "package:km.ci" "package:survival"
[4] "package:splines" "package:stats" "package:graphics"
[7] "package:grDevices" "package:utils" "package:datasets"
[10] "package:methods" "Autoloads" "package:base"
非常感谢!
编辑:感谢 DWin,对不起,我错过了help(Surv)
.
但是我仍然收到相同的错误消息。我正在阅读帮助:
quantile.survfit {survival}
它被记录为 S3 泛型,所以我期待 usingquantile(f1)
应该调用此方法。
但是我发现以下方法不起作用:
survival:::quantile.survfit(f1)
给出:
Error: 'quantile.survfit' is not an exported object from 'namespace:survival'
尝试重新安装survival,它仍然是最新版本:survival_2.36-10