R / gtsummary:排除一些p值并更改脚注

时间:2020-04-30 19:43:19

标签: r gtsummary

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

还可以更改所用测试的脚注吗?

library(gtsummary)

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

2 个答案:

答案 0 :(得分:2)

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

首先,可以将include =函数的add_p()参数与要包含(或排除使用-)的变量的字符向量一起使用,也可以将任何{ {3}}(即starts_with()),以选择要在表格中包含哪些p值。

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

祝您好运,希望对您有帮助!

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

tidyselect helper

答案 1 :(得分:1)

另一种方法是直接对列表进行周:

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

enter image description here