尝试绘制多个数据集时出现ggsurvplot错误

时间:2018-08-01 01:56:53

标签: r statistics

我想在同一张图上绘制许多来自不同研究的残差对象。

研究时间长短不一,但我想不出任何其他主要差异。

下面是我的代码:

#Fitting ambristentan data
ambri_surv_fit <- survfit(Surv(event_time, censor)~1, data=ambri_mono)

#Fitting tadalafil data
tada_surv_fit <- survfit(Surv(event_time, censor)~1, data=tada_mono)

#Fitting macitentan data
maci_surv_fit <- survfit(Surv(event_time, censor)~1, data=maci_mono)

#Fitting maci_control mono data
maci_control_mono_surv_fit <- survfit(Surv(event_time, censor)~1, data=maci_control_mono)

surv_fit_list <- list(ambri_surv_fit,
                     tada_surv_fit,
                     maci_surv_fit,
                     maci_control_mono_surv_fit)

ggsurvplot(surv_fit_list, combine=TRUE)

我得到的错误:

Error in names(fit) <- fitnames : 
  'names' attribute [2828] must be the same length as the vector [4]

我希望它看起来如何:

enter image description here

1 个答案:

答案 0 :(得分:0)

结果是您必须命名列表:

surv_fit_list <- list("ambirsentan monotherapy" =ambri_surv_fit,
                     "tadalafil monotherapy" = tada_surv_fit,
                     "macitentan monotherapy" = maci_surv_fit,
                     "macitentan control monotherapy" = maci_control_mono_surv_fit)
相关问题