簡體   English   中英

如何使用 tbl_summary 顯示方差分析的測試統計量(F 值)

[英]How do I display test statistic (F value) for anova using tbl_summary

這是我用來輸出方差分析匯總表的代碼:

hiv %>% 
  select(education, sexfirsttime) %>% 
  mutate(education=
  factor(education, levels= c("no education", "primary","secondary","college"))) %>% 
  tbl_summary(missing="no", 
              by=education,
    statistic = all_continuous() ~"{mean} ({sd})", 
    label = sexfirsttime ~ "Age of first time sex") %>% 
  add_p(test= all_continuous() ~ "aov") %>% 
  modify_header(statistic ~ "**Test Statistic**") 

執行代碼后,我收到以下錯誤消息:錯誤: update=參數輸入中的錯誤。 從'變量'、'test_name'、'var_type'、'var_label'、'row_type'、'label'、'stat_1'、'stat_2'、'stat_3'、'stat_4'、'test_result'、'p.value'中選擇'

當我嘗試替換statistic與modify_header test_result ,輸出,我得到一個匪夷所思的輸出顯示的是形象。

我對使用gtsummary 任何幫助將不勝感激。 謝謝你。

使用最新版本的 gtsummary 並重試。 在最新版本中,“aov”測試的處理與其他測試更加一致,包括返回“統計”列。

library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.5.0'

tbl <- 
  trial %>%
  select(grade, age, marker) %>%
  tbl_summary(
    by = grade, 
    missing = "no"
  ) %>%
  add_p(all_continuous() ~ "aov") %>%
  # add a header (which also unhides a hidden column)
  modify_header(statistic ~ "**Test Statistic**") %>%
  # add a function to format the column
  modify_fmt_fun(statistic ~ style_sigfig)

在此處輸入圖片說明 reprex 包(v2.0.1) 於 2021 年 10 月 17 日創建

暫無
暫無

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

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