【问题标题】:R/gtsummary: Exclude some p-values and change the footnoteR/gtsummary:排除一些 p 值并更改脚注
【发布时间】:2020-08-15 07:01:14
【问题描述】:

有谁知道是否可以从汇总表中排除一些 p 值(tbl_summary()add_p())?

另外,我们可以更改所用测试的脚注吗?

library(gtsummary)

mtcars %>%
tbl_summary(by = am) %>%
add_p()

【问题讨论】:

    标签: r gtsummary


    【解决方案1】:

    另一种方法是直接 tweek 列表:

    plouf <- mtcars %>%
      tbl_summary(by = am) %>%
      add_p()
    plouf$table_body[1,"p.value"] <- NA
    plouf$table_header[6,"footnote"] <- "my personal statistic test"
    plouf
    

    【讨论】:

      【解决方案2】:

      这些都是很棒的自定义问题,答案是肯定的!

      首先,您可以使用 add_p() 函数的 include = 参数,以及要包含的变量的字符向量(或使用 - 排除),或任何 tidyselect helper(即 @987654328 @),以选择要包含在表中的 p 值。

      接下来,我提供了一个使用 {gt} 包中的参数的示例,说明如何修改默认脚注列表测试。另一个例子可见{gtsummary} gallery of tables

      祝你好运,希望这会有所帮助!

      library(gtsummary)
      library(dplyr, warn.conflicts = F)
      library(gt)
      
      trial %>% 
        select(trt, stage, age, grade) %>% 
        tbl_summary(by = trt) %>% 
        add_p(
          include = c(-age) #Can use any tidyselect helpers/select syntax to specify which p-vals
        ) %>% 
        as_gt(include = -tab_footnote) %>%  # if using gt, can exclude footnotes this way 
        tab_footnote( # and can modify/add footnotes this way
          footnote = "Tests used are...",
          locations = cells_column_labels(columns = vars(p.value))
        )
      
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-02-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-11-02
        • 2021-02-21
        相关资源
        最近更新 更多