This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error with ggsurvplot function for survival analysis

I'm trying to make a KM plot using ggsurvplot but I'm getting an error.

fit <- survfit(Surv(Months, progression) ~ group, data=new)

ggsurvplot(fit,
           data = new,
           risk.table = TRUE,
           pval = TRUE,
           break.time.by = 500,
           ggtheme = theme_minimal(),
           risk.table.y.text.col = TRUE,
           risk.table.y.text = FALSE)

Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘"by"’ to a data.frame

Here's an example of my data:

Months  group  progression
 53      low    0
 34      low    0
 55      low    0
 36      low    0
 54      low    0
 54      low    0
 46      low    0
 88      low    1
 12      high   0
 43      high   0
 32      high   1
 23      high   1
 24      high   1
 64      high   1
 73      high   1
 24      high   1
 54      high   0
software error

Please hightlight code and data examples with the code option. That makes the most visually more appealing.

enter image description here

0 answers

No answers yet.

Log in to answer this question.