【发布时间】:2020-08-15 07:01:14
【问题描述】:
有谁知道是否可以从汇总表中排除一些 p 值(tbl_summary() 和 add_p())?
另外,我们可以更改所用测试的脚注吗?
library(gtsummary)
mtcars %>%
tbl_summary(by = am) %>%
add_p()
【问题讨论】:
有谁知道是否可以从汇总表中排除一些 p 值(tbl_summary() 和 add_p())?
另外,我们可以更改所用测试的脚注吗?
library(gtsummary)
mtcars %>%
tbl_summary(by = am) %>%
add_p()
【问题讨论】:
这些都是很棒的自定义问题,答案是肯定的!
首先,您可以使用 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))
)
【讨论】: