Home > OS >  How to delete CI interval column in gtsummary package when displaying differences between two groups
How to delete CI interval column in gtsummary package when displaying differences between two groups

Time:10-19

By default, the function add_diference() in the gtsummary R package creates three columns: Difference, 95% CI and p-value. Does anyone knows hot to delete the CI column?

I tried to access the table_styling$header to hide the columns, but it is already as "FALSE".

Thanks

CodePudding user response:

Use the modify_column_hide() function to hide the 95% CI. Happy Programming!

library(gtsummary) 
packageVersion("gtsummary")
#> [1] '1.5.0'

trial %>%
  select(age, marker, trt) %>%
  tbl_summary(missing = "no", by = trt) %>%
  add_difference() %>%
  modify_column_hide(ci) %>%
  as_kable() # convert to kable to display on SO
Characteristic Drug A, N = 98 Drug B, N = 102 Difference p-value
Age 46 (37, 59) 48 (39, 56) -0.44 0.8
Marker Level (ng/mL) 0.84 (0.24, 1.57) 0.52 (0.19, 1.20) 0.20 0.12

Created on 2021-10-18 by the reprex package (v2.0.1)

  • Related