Reputation: 423
After running a model e.g. cox model, I would like to change the default variable values on the table rows e.g. instead of the default Grade variable values: "I", "II", "III", I would like to have "A", "B", "C" respectively displayed instead.
Here is an example code:
coxph(Surv(ttdeath, death) ~ trt + grade + age, trial) %>%
tbl_regression(exponentiate = TRUE)
Thank you!
Upvotes: 1
Views: 1022
Reputation: 11754
The method to make this change is the same for all gtsummary tables: update your data before you pipe it into the summarizing table.
library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.3.6'
tbl <-
trial %>%
select(grade) %>%
# update grade levels
mutate(grade = factor(grade, labels = c("A", "B", "C"))) %>%
tbl_summary()
Created on 2021-01-14 by the reprex package (v0.3.0)
Upvotes: 2