gtsummary , 5 point complex survey design scale and median

I am trying to use the tbl_svysummary for a likert scale survey ordinal data: “very bad”, “bad”, “moderate”, “good”, “very good” and I have five such questions are there.

I need to summaries the median.

Could not find any example

You can use the tbl_likert() function for this from the bstfun package (which includes gtsummary extensions)
https://mskcc-epi-bio.github.io/bstfun/reference/tbl_likert.html

set.seed(1123)
likert_lvls <- c("Never", "Sometimes",  "Often", "Always")

df <-
  tibble::tibble(
    Q1 = sample(likert_lvls, size = 100, replace = TRUE),
    Q2 = sample(likert_lvls, size = 100, replace = TRUE)
  ) %>%
  mutate(across(c(Q1, Q2), ~factor(., levels = likert_lvls)))

tbl_likert_ex1 <-
  tbl_likert(df) %>%
  add_n() %>%
  add_continuous_stat(statistic = "{mean}") %>%
  add_continuous_stat(statistic = "{sd}")

enter image description here

Leave a Comment