Hi, apologies for my noobishness in advance. I am attempting to plot a survival curve of time to patient death/retransplant using the ggsurvplot function, with two groups defined by their liver transplant having had an arterial construction or not.
Actual behavior
No curve produce. Error given:
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 236, 0, 472
My R studio and relevant packages appear to be working as I am able to reproduce the standard lung cancer examples, but have clearly done something wrong with my dataset.
Steps to reproduce the problem
library(survival)
library(survminer)
library(dplyr)
library(readr)
github_survival_curve <- read_csv("dataraw/github _survival_curve.csv",
col_types = cols( Any arterial reconstruction (0-No, 1-yes)
= col_factor(levels = c("0",
"1")), Event_death = col_factor(levels = c("0",
"1")), Graft_survival = col_integer(),
Survival_to_retransplantation = col_integer()))
View(github_survival_curve)
surv_object <- Surv(time = github_survival_curve$Graft_survival, event = github_survival_curve$Event_death)
surv_object
fit1 <- survfit(surv_object ~ github_survival_curve$ Any arterial reconstruction (0-No, 1-yes)
, data = github_survival_curve)
summary(fit1)
ggsurvplot(fit1, data = github_survival_curve, pval = TRUE)
All steps appear to be functioning well apart from the final step which returns:
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 236, 0, 472
Any help or advice would be greatly appreciated, have searched similar issues, but I seem to have stalled at a much earlier junction than most of those.