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

tbl_survfit ignores factor levels order in stratification variable for survfit objects #764

Closed
michaelcurry1123 opened this issue Feb 5, 2021 · 0 comments · Fixed by #765

Comments

@michaelcurry1123
Copy link
Collaborator

If you want to specify factor level order it is ignored in tbl_survfit() . Example below

library(gtsummary)
library(survival)
# make 0 drug b and first factor level 
trial <- mutate(trial, trt = ifelse(trt == "Drug A",1,0),
                trt = factor(trt, levels = c(0,1),labels = c("Drug B", "Drug A")))

mod1 <- survfit(Surv(ttdeath, death)~trt,trial)

mod2 <- coxph(Surv(ttdeath, death)~trt, trial)
# tbl_survfit still puts drug a first
tbl_survfit(mod1, times = 12, sort = c("Drug B", "Drug A"))
# factor level respected in cox model/ tbl_regression 
tbl_regression(mod2)

ddsjoberg added a commit that referenced this issue Feb 7, 2021
ddsjoberg added a commit that referenced this issue Feb 16, 2021
* #764 fct order bug fix in survfit

* Update test-tbl_survfit.R

* Update add_global_p.R

* updated news and bumped version number

Co-authored-by: michaelcurry1123 <30420015+michaelcurry1123@users.noreply.github.com>
Co-authored-by: Curry <currym1@mskcc.org>
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.

1 participant