maia-sh
maia-sh

Reputation: 641

Change `gtsummary::tbl_regression` columns

I would like to reformat the column in gtsummary::tbl_regression similar to tbl_summary using the statistic argument. However, I cannot find the corresponding argument to make this adjustment. Thank you for your help pointing me to the argument!

For example, instead of:

library(dplyr)
library(gtsummary)

glm(response ~ age, trial, family = binomial(link = "logit")) %>%
  tbl_regression(exponentiate = TRUE)

Created on 2021-07-13 by the reprex package (v0.3.0)

gtsummary-tbl

I would like:

Characteristic OR (95% CI; p value)
Age 1.02 (1.00,1.04; 0.10)

Upvotes: 0

Views: 1032

Answers (1)

Daniel D. Sjoberg
Daniel D. Sjoberg

Reputation: 11784

You can merge columns in gtsummary, but I will say that this feature is not documented for users because it is still being thought out and it is possible that is implementation may change slightly in a future release. Example below!

library(gtsummary)

glm(response ~ age, trial, family = binomial(link = "logit")) %>%
  tbl_regression(exponentiate = TRUE) %>%
  modify_table_styling(
    column = estimate, 
    rows = !is.na(estimate),
    cols_merge_pattern = "{estimate} ({ci}; {p.value})",
    label = "**OR (95% CI; p value)**"
  ) %>%
  modify_footnote(estimate ~ "OR = Odds Ratio, CI = Confidence Interval",
                  abbreviation = TRUE)

enter image description here

Upvotes: 1

Related Questions