Search code examples
rlogistic-regressionconfidence-intervalgtsummary

Insert dash in confidence interval instead of comma in R (gtsummary)


I am doing a logistic regression table with tbl_regression (gtsummary package). However, confidence intervals are displayed with a comma in between. Is there a way to put a dash instead?

enter image description here

So that it would be displayed 1.04 - 1.05 instead of 1.04, 1.05.


Solution

  • I would consider creating a custom theme with gtsummary. One of the theme elements is ci.sep which is the:

    string indicating separator between upper and lower bounds of confidence intervals

    The default is a comma, and could be set to endash or other. Other journal themes may already consider this for confidence intervals.

    Here is an example using trial data from the package.

    library(gtsummary)
    
    m1 <- glm(response ~ age + stage, trial, family = binomial)
    
    my_theme <-
      list(
        "pkgwide-str:ci.sep" = " - "
      )
    
    set_gtsummary_theme(my_theme)
    
    tbl_regression(m1, exponentiate = TRUE)
      
    

    Output

    table with dash for confidence interval instead of comma