Adilson Bauhofer
Adilson Bauhofer

Reputation: 1

R gtsummary package: How to Hide Colums in Summary Table

I'm using gtsummary to prepare my tables, I'm trying to hide one of the columns from the groups, the third column labeled as "1, N = 61"

Below is the code ran,

library(gtsummary)
trial <- trial
trial %>% 
tbl_summary(by=response,
            statistic = list(trt~"{n}/{N} ({p}%)")) %>% 
  add_overall() %>%
  add_p() %>% 
  modify_column_hide(columns = "1")

The output provided

I was expecting that the third column would be hidden "1, N = 61"

Upvotes: 0

Views: 898

Answers (1)

PTS390
PTS390

Reputation: 43

The 2 columns (0 , 1) are named "stat_1" and "stat_2" respectively.

So, to hide the one you ask for:

trial %>% 
  tbl_summary(by=response,
              statistic = list(trt~"{n}/{N} ({p}%)")) %>% 
 
  modify_column_hide(columns = "stat_2") %>%
  
  add_p() %>%
  add_overall() 

Output:

enter image description here

Now, if you want to hide parameters of statistical tests you run, you would do it as indicated here:

https://rdrr.io/cran/gtsummary/man/modify_column_hide.html

Upvotes: 0

Related Questions