I can’t figure out what the problem is with drawing Kaplan Meier curves using ggsurvplot from the survminer and survival package for two-group comparison of survival until day 60. I can create a survival object with Surv() and survdiff(), but when using it inside ggsurvplot(), i get the error: “Error in ggsurvplot(fit_test) : object ‘ggsurv’ not found”.
I installed the latest versions of both survival and survminer, and using Rstudio 2023.09.0 Build 463
here is my sample data with s_time for time to event, s_event for event 0/1, and s_group for comparative stratification of groups.
library(survival)
library(survminer)
df_surv <- data.frame(s_time = c(13,14,1,3,23,45,60,60,60,60,60,57,33,44,27,2,6,9,39,46,51,19, 22, 35,21),
s_event = c(1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,1,1,1,1,1),
s_group = c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0))
fit <- survdiff(Surv(s_time, s_event)~s_group, data = df_surv)
ggsurvplot(fit, data = df_surv)
Anybody else encontered this error? Thanks alot for any help.