我想跑ggsurvplot_facet()
但跑不过去Error in model.frame.default(formula = surv_object2 ~ id, data = list( :variable lengths differ (found for 'id')
。任何帮助将不胜感激。
我相信错误在survfit()
/surv_fit()
组件中,而不是在ggsurvplot_facet()
组件中。
数据可以在这里找到。
我的代码如下:
library(survival); library(survminer)
read.csv(file = 'test.csv', header = TRUE)
surv_object <- Surv(time = test$Days_survived, event = test$Event1)
fit <- survfit(surv_object ~ id, data = test)
ggsurvplot_facet(fit = fit, data = test, facet.by = "method", pval = TRUE)
# I have also tried, without success
fit <- survfit(Surv(join$Days_survived, join$Event1) ~ id, data = join)
ggsurvplot_facet(fit = fit, data = test, facet.by = "method", pval = TRUE)
# and
fit <- survfit(as.formula(paste("Surv(join$Days_survived, join$Event1) ~", id)), data = join)
ggsurvplot_facet(fit = fit, data = test, facet.by = "method", pval = TRUE)
# and
fit <- survfit(as.formula(paste('Surv(join$Days_survived, join$Event1) ~', id)), data = join)
ggsurvplot_facet(fit = fit, data = test, facet.by = "method", pval = TRUE)
# and
fit <- survfit(as.formula(Surv(join$Days_survived, join$Event1) ~ id), data=join)
ggsurvplot_facet(fit = fit, data = test, facet.by = "method", pval = TRUE)
我还使用该surv_fit()
功能尝试了上述所有组合。
再次感谢。