2

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

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

library(gtsummary)

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

2 回答 2

2

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

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

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

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

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))
  )

在此处输入图像描述

于 2020-04-30T20:28:20.650 回答
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

在此处输入图像描述

于 2020-04-30T20:50:24.593 回答