I need to display multiple logistic regressions in the same table and as I use gtsummary tables elsewhere in the document I am wondering if there is an idiomatic way of doing it with gtsummary? The data are univariate logistic regression results on the different factors in one column as well as multivariate logistic regressions on the same factors, displayed side by side.
Consider the following example as illustration using the trial dataset:
library(gtsummary)
mdls <- list()
for (stage in levels(trial$stage)) {
mdls[[stage]] <- list(
uv = glm(I(stage == stage) ~ death, data = trial, family = "binomial"),
mv = glm(I(stage == stage) ~ death + age, data = trial, family = "binomial")
)
}
I am trying to figure out how to create a table that looks something like this (invented data):

Any pointers and how to achieve this, whether which gtsummary functions to use, or how to assemble the data to feed to gtsummary, or if I should forgo gtsummary for this and "build the table manually" with gt?
I have tried various "hacky" approaches, like creating indivdual tables for each regression, dropping all rows except the relevant one, change the row characteristic and then tbl_stack() and tbl_merge() to a final table. It works but it's not pretty. Similarly I have tried manually crafting a tibble to feed to tbl_summary() that looks correct which also works but is equally ugly. These solutions end up being a lot more complex than simply building the table with gt and then style the same as gtsummary.
You can create a table
univfor the univariate regressions usingtbl_uvregression(see here)And then create a table
multivwith the multivariable regression usingtbl_regression(see here)Then merge these two tables using
tbl_merge:table <- tbl_merge(tbls = list(univ, multiv), tab_spanner = c("**Univariable**", "**Multivariable**"))This should place the univariate and multivariate results next to each other in one table. Try if this works!