I used tbl_regression and add_glance_table() from gtsummary
to build a table with model statistic:
library(gtsumary)
coxph(Surv(time, event) ~ score, data = dat) %>%
tbl_regression(exponentiate = TRUE) %>%
add_glance_table(concordance)
1st question: How can I move the model statistic horizontaly, to the right?
Because, in the end, I want to display multiple model statistic, with C index in the last column, like this:
tbl_uvregression(
dat_score,
method=survival::coxph,
y = Surv(time, event),
exponentiate = TRUE)
2nd question: How do I add add_glance_table
in tbl_uvregression
?
You can merge any additional columns/statistics into a gtsummary using the
modify_table_body()
function (thetable_body
is an internal data frame that is styled and printed as the summary table).It's possible to add the c-index in a
tbl_uvregression()
setting. But I think it requires a higher understanding of the internals of atbl_uvregression()
object. In the example below, I estimate each univariable model separately, summarize the model withtbl_regression()
, merge in the c-index, then stack all the tbls withtbl_stack()
.Happy Programming!
Created on 2022-04-09 by the reprex package (v2.0.1)