如何将N添加到R中带有gtsummary的跨越标题标签中?

6ie5vjzr  于 2022-12-20  发布在  其他
关注(0)|答案(1)|浏览(131)

我正在使用试用数据库,我想在成绩后面添加N。我认为需要添加N = {n}来修改_spanning_header,但我不知道如何实现。
下面是代码:

trial %>%
    select(trt, grade, age, stage) %>%
    mutate(grade = paste("Grade", grade)) %>%
    tbl_strata(
        strata = grade, 
        ~.x %>%
            tbl_summary(by = trt, missing = "no") %>%
            modify_header(all_stat_cols() ~ "**{level}**")
    )
64jmpszr

64jmpszr1#

示例如下!

library(gtsummary)
packageVersion("gtsummary")

tbl <- 
  trial %>%
  select(trt, grade, age, stage) %>%
  mutate(grade = paste("Grade", grade)) %>%
  tbl_strata(
    strata = grade, 
    ~.x %>%
      tbl_summary(by = trt, missing = "no") %>%
      modify_header(all_stat_cols() ~ "**{level}**"),
    .header = "**{strata}** N={n}"
  )

相关问题