-1

I am making my demographics table using gtsummary. I want the confidence interval in my table to appear between [] not (). For example,

  trial %>%
    select(response, grade) %>%
    tbl_summary(statistic = all_categorical() ~ "{p}%",
                missing = "no") %>%
    modify_footnote(everything() ~ NA) %>%
    add_ci()

This produces:

enter image description here

I appreciate your help

PTS390
  • 33
  • 1
  • 2
  • 12
  • 2
    Please update your post with a minimal reproducible example (aka a reprex): something we can run on our machines. The gtsummary pkg comes with a data frame called 'trial'. The code you've provided does not create a table with a confidence interval, so I am not sure what table you're trying to create. – Daniel D. Sjoberg Sep 11 '22 at 11:28

2 Answers2

0

Sorry I made a mistake I want the IQR to appear between []

Here is an example.

library(gtsummary)
data=colon
tbl_summary(data=colon, by=rx, missing='no')

enter image description here

for.example nodes 2.0 (1.0, 5.0) to 2.0 [1.0, 5.0]

Helio
  • 621
  • 1
  • 4
  • 24
0

at least about the CI, you can add this to your code:

trial %>%
  select(response, grade) %>%
  tbl_summary(statistic = all_categorical() ~ "{p}%",
              missing = "no") %>%
  modify_footnote(everything() ~ NA) %>%
  
  add_ci(pattern = "{stat} [{ci}]") 

enter image description here

As for the IQR, here is an example

  trial %>%
    select(age) %>%
    tbl_summary(
                statistic =  all_continuous() ~ "{mean} [{IQR}]",
                missing = "no") 

enter image description here

PTS390
  • 33
  • 1
  • 2
  • 12