【发布时间】:2013-07-17 08:51:10
【问题描述】:
我需要在R中cox.zph函数的输出中提取特定行的p属性。
为了让您有疑问,我将我的问题描述如下,并通过一个示例逐步说明:
require('survival')
# I create the simplest test data set
test1 <- list(time=c(4,3,1,1,2,2,3),
status=c(1,1,1,0,1,1,0),
x=c(0,2,1,1,1,0,0),
sex=c(0,0,0,0,1,1,1))
# Fit a stratified model
coxmodel <- coxph(Surv(time, status) ~ x + strata(sex), test1)
然后,我使用cox.zph函数:
zph <- cox.zph(coxmodel)
输出如下:
rho chisq p
x 0.354 0.322 0.57
我试图通过使用attributes(zph) 来获取p 属性值(在本例中为0.57),但p 没有出现以执行zph$p 之类的操作。我还使用了plyr 包,但没有结果。
有人可以帮助我吗?谢谢。
【问题讨论】:
标签: r function extract text-extraction information-extraction