I am making a descriptive table of categorical variables. gtsummary::tbl_summary combined with as_flextable and my own flextable adjustments gives me the APA-formatted table I want, with frequencies and percentages.
However, I would like indices to be in separate columns.
I have been looking for ways to adapt this code to get separate N and % columns instead of N (%)
trial2 <- gtsummary::trial |> dplyr::select(trt, age, grade)
trial2 |> gtsummary::tbl_summary() %>% gtsummary::as_flex_table()
Any suggestions?
You can use tbl_wide_summary()
. https://www.danieldsjoberg.com/gtsummary/reference/tbl_wide_summary.html
trial |>
tbl_wide_summary(include = c(response, grade)