gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 11:00:56 27 4
gpt4 key购买 nike

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

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

library(gtsummary)

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

最佳答案

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

首先,可以将include =函数的add_p()参数与要包含(或使用-排除)或任何tidyselect helper(即starts_with())变量的字符向量一起使用,选择要包含在表格中的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))
)



enter image description here

关于r - R/gtsummary:排除一些p值并更改脚注,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61531464/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com