Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: add_nevent throws an error when using tbl_survfit + survfit2 #1389

Closed
kentm4 opened this issue Nov 21, 2022 · 1 comment · Fixed by #1390
Closed

Bug Report: add_nevent throws an error when using tbl_survfit + survfit2 #1389

kentm4 opened this issue Nov 21, 2022 · 1 comment · Fixed by #1390

Comments

@kentm4
Copy link

kentm4 commented Nov 21, 2022

The following code throws Error: Each of the survfit() objects must have class 'survfit' only. Multi-state models are not supported by this function. but using survfit instead of survfit2 the add_nevent() function works as expected. In most cases, it would be nice to create one model using survfit2 for KM plots using ggsurvfit and then passing the same model to the table functions (instead of switching to survfit for the tables.

library(gtsummary)

my_surv_model <- survfit2(Surv(time = time, event = status) ~ rx, data = df_colon)

tbl_survfit(
  x = my_surv_model,
  times = c(1, 2, 5),
  label_header = "**{time}-Year Survival**",
)  %>% 
  add_n() %>%
  add_nevent()
@ddsjoberg
Copy link
Owner

Sure, this check can be relaxed for survfit2 objects. I'll leave this open for now. not sure when i'll get to the update FYI

@ddsjoberg ddsjoberg mentioned this issue Nov 24, 2022
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants