使用来自survMisc包

时间:2016-01-04 14:48:43

标签: r plot survival-analysis

我正在使用survMisc包中的autoplot函数来绘制生存曲线和风险表中的数字:

autoplot(autoplot(survfit((Surv(deathcens.allograft.surv.years.to5y, deathcens.allograft.surv.cens.to5y) ~ AT.interval.10min ), data =  ETdata), censSize=0, type="CI", legTitle = NULL, legLabs=c("<35min", "35-44 min", "45-54 min", ">=55min"), ylim=c(0.4, 1.0), yLab="death-censored graft survival", xLab="Time after transplantation (years)", pVal=TRUE, pY=0.96, pX=0.80)

不幸的是,我没有成功将y轴改为0.4-1.0 我尝试了几种方法:

(i)添加 + ggplot2 :: scale_y_continuous(limits = c(0,1))

autoplot(autoplot(survfit((Surv(deathcens.allograft.surv.years.to5y, deathcens.allograft.surv.cens.to5y) ~ AT.interval.10min.3 ), data =  ETdata.ATrange10.200.FU.DBD), censSize=0, type="CI", legTitle = NULL, legLabs=c("<35min", "35-44 min", "45-54 min", ">=55min"), ylim=c(0.4, 1.0), title= "Brain-death donors", yLab="death-censored graft survival", xLab="Time after transplantation (years)", pVal=TRUE, pY=0.96, pX=0.80) + ggplot2::scale_y_continuous(limits=c(0, 1)))

这将返回错误: autoplot中的错误(survfit((Surv(deathcens.allograft.surv.years.to5y,deathcens.allograft.surv.cens.to5y)〜:   二元运算符的非数字参数

(ii)将 ylim = c(0.4,1.0)添加到函数

通过

autoplot(autoplot(survfit((Surv(deathcens.allograft.surv.years.to5y, deathcens.allograft.surv.cens.to5y) ~ AT.interval.10min ), data =  ETdata), censSize=0, type="CI", legTitle = NULL, legLabs=c("<35min", "35-44 min", "45-54 min", ">=55min"), ylim=c(0.4, 1.0), yLab="survival", xLab="Time", pVal=TRUE, pY=0.96, pX=0.80))

OR

autoplot(autoplot(survfit((Surv(deathcens.allograft.surv.years.to5y, deathcens.allograft.surv.cens.to5y) ~ AT.interval.10min ), data =  ETdata), censSize=0, type="CI", legTitle = NULL, legLabs=c("<35min", "35-44 min", "45-54 min", ">=55min"), yLab="survival", xLab="Time", pVal=TRUE, pY=0.96, pX=0.80) + ylim(c(0.4,1.0)))

OR

autoplot(autoplot(survfit((Surv(deathcens.allograft.surv.years.to5y, deathcens.allograft.surv.cens.to5y) ~ AT.interval.10min ), data =  ETdata), censSize=0, type="CI", legTitle = NULL, legLabs=c("<35min", "35-44 min", "45-54 min", ">=55min"), yLab="survival", xLab="Time", pVal=TRUE, pY=0.96, pX=0.80)) + ylim(c(0.4,1.0))

返回:错误:找不到函数“ylim”

(iii)在函数中添加* + coord_cartesian(ylim = c(0.4,1.0))*

autoplot(autoplot(survfit((Surv(deathcens.allograft.surv.years.to5y, deathcens.allograft.surv.cens.to5y) ~ AT.interval.10min ), data =  ETdata), censSize=0, type="CI", legTitle = NULL, legLabs=c("<35min", "35-44 min", "45-54 min", ">=55min"), yLab="survival", xLab="Time", pVal=TRUE, pY=0.96, pX=0.80)) + coord_cartesian(ylim= c(0.4, 1.0)) 
有人可以帮帮我吗? 谢谢!

0 个答案:

没有答案