0

Is it possible to create a table of characteristics that would keep the number of unweighted observations (n) followed by the weighted percentage formatted as a combination of the two codes above?

attached the unweighted summary, and the weighted summary. need to keep the unweighted N by the weighted percentage for all categories.[enter image description here](https://i.stack.imgur.com/KV4AL.jpg)

library(gtsummary)

x <- survey::svydesign(~1, data = dsteps_df, weights = ~p_wstep) %>%
  tbl_svysummary(
    by = p_sexe,
    include = c(p_age_4cl),
    digits = list(
      all_continuous() = 1,
      all_categorical() = c(0, 1)
    ),
    statistic = list(
      all_continuous() = "{n} ({N_unweighted})",
      all_categorical() = "{n} ({N_unweighted})"
    )
  ) %>%
  modify_stat(
    all_stat_cols() ~ "{p} ({style_percent(p, digits = 1)})"
  ) %>%
  add_overall(last = FALSE) %>%
  missing_text("Missing observations") %>%
  bold_labels()

x

  • I have tried that code which was unsuccessful – McDaniels Kouamivi Aug 15 '23 at 19:44
  • 1
    Hi, welcome to the stack! You're not likely to get much help without a [minimal, reprodubile example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), which you can create using commands like `dput()`. Pictures of data are not especially helpful for reproducing your problem. – Captain Hat Aug 16 '23 at 10:56

0 Answers0