簡體   English   中英

R/gtsummary:排除一些 p 值並更改腳注

[英]R/gtsummary: Exclude some p-values and change the footnote

有誰知道是否可以從匯總表( tbl_summary()add_p() )中排除一些 p 值?

另外,我們可以更改有關所用測試的腳注嗎?

library(gtsummary)

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

這些都是很棒的定制問題,答案是肯定的!!

首先,您可以使用add_p() function 的include =參數,以及要包含(或使用-排除)的變量的字符向量,或任何tidyselect 助手(即starts_with() )到 select 其中 p -要包含在表中的值。

接下來,我提供了一個使用來自 {gt} package 的 arguments 的示例,說明如何修改默認腳注列表測試。 另一個例子可以在 表的 {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))
  )

在此處輸入圖像描述

另一種方法是直接 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

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM