GMJ
GMJ

Reputation: 75

Renaming Rows in gtsummary, tbl_regression/tbl_stack

I am using gtsummary and have stacked tables for the outputs of 11 different models on top of one another using the tbl_regression and tbl_stack functions. I am looking to see how the odds ratios of one consistent independent variable change across different dependent variables of interest. When I print out the tbl_stack output, it gives me 11 repeated rows of the independent variable name of interest, instead of the name of the unique dependent variables I am interested in. Does anyone know how to rename rows in tbl_stack (either manually or automatically) to put the dependent variable names in the rows?

Thank you.

Upvotes: 2

Views: 1700

Answers (1)

Daniel D. Sjoberg
Daniel D. Sjoberg

Reputation: 11680

You can use the tbl_regression(label=) argument to change the labels for the repeating variable to match the outcome for each model before you stack them.

There is, however, a shortcut using tbl_uvregerssion().

library(gtsummary)
packageVersion("gtsummary")
#> '1.3.6'

trial %>%
  select(response, death, age) %>%
  tbl_uvregression(
    x = age, 
    method = glm,
    method.args = list(family = binomial),
    exponentiate = TRUE
  ) %>%
  modify_header(label ~ "**Outcome**")

enter image description here

Upvotes: 2

Related Questions