0

Data: There are other covariates aswell but these are the 3 main variables. I have changed pdc_80_v0 to factor

death_fu_time_18m DeathFlag_18m pdc_80_v0
500 0 1
200 1 0
450 0 1
390 1 1
420 1 0
200 0 1
km_treat_t1 <- survfit(Surv(time = death_futime_18m, event = DeathFlag_18m) ~ pdc_80_v0, 
                       data = cgm_t1_excl_upd %>% filter(.imp == 1),
                       #type = 'kaplan-meier',
                       ctype = 1, stype = 1)
#survival times, every 90 days
summary(km_treat_t1, times = c(seq(1, 548, by = 90)))


#plot
plot(km_treat_t1) 

This code runs properly but is not much descriptive ggsurvplot(km_treat_t1, conf.int = 'True', risk.table = T, ylim = c(0.80, 1.0)) For this I am getting error that says error in data frame, argument implies differing number of rows 419, 0, 838

Code tried: Initially I got error in the survfit function for type = kapla-meier and hence changed the argument to ctype and stype

  • It would be helpful to share data using `dput` and make a [reproducible example](https://stackoverflow.com/a/5963610/3460670). – Ben Apr 05 '23 at 14:39
  • Updated with the data – Sharon Macwan Apr 05 '23 at 16:24
  • I was able to use the example data and run the code provided, and did not get any error. I did need to correct spelling `death_futime_18m` but that was pretty much it. Did you try to reproduce your error with your example data above? – Ben Apr 05 '23 at 16:34
  • yes at first it didnot let me add the type as kaplan-meier so I had to change the type. did u change the pdc variable to factor when u ran the code? – Sharon Macwan Apr 05 '23 at 16:47
  • yes, i have `pdc_80_v0` as a factor, without an error or problem. Using `dput` would give a better representation of your data...you can do `dput(head(cgm_t1_excl_upd))` and edit your post with the results...that will give a sample of data to work with...also, make sure to update your code with exactly what you have (add libraries)...and restart R session before running again? – Ben Apr 05 '23 at 17:36
  • Thank you I played around a little and the code worked turns out that my death_flag_18m was not numeric – Sharon Macwan Apr 05 '23 at 22:07
  • Glad to hear this is resolved, and probably comes up a lot. We like to use `dput` to share data for this reason too. With `dput` we can see the structure and data types easily and exactly as you have it. Good luck with result of your work! – Ben Apr 06 '23 at 13:27
  • Voting to close as not reproducible. – IRTFM Apr 06 '23 at 20:36

0 Answers0