I have dataset like the following
> head(n2)
# A tibble: 6 x 4
  Pain  Redness Swelling Tiredness
  <fct> <chr>   <chr>    <chr>    
1 Yes   No      No       Yes      
2 No    No      No       No       
3 Yes   No      No       Yes      
4 Yes   No      Yes      Yes      
5 No    No      No       No       
6 No    No      No       No        
I am trying to make a summary table using gtsummary package. But in the summary table it is not showing the "Yes"/ "No" levels of Pain, Redness or Swelling variables, but rather it just shows the count of Yes of each columns. Can someone please help to show the "Yes"/ "No" levels in the table 
We could use type argument of tbl_summary().
See here: https://www.danieldsjoberg.com/gtsummary/reference/tbl_summary.html under type argument:
library(dplyr)
library(gtsummary)
df %>% 
  mutate(across(everything(), ~factor(., levels = c("Yes", "No")))) %>% 
  tbl_summary(
    type = list(c(Pain, Redness, Swelling, Tiredness) ~ "categorical")
  ) 

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With