繁体   English   中英

添加多个 `add_n`

[英]Add more than one `add_n`

是否可以添加多个add_n 以下代码返回以下警告,并且未添加任何add_n 两者都靠自己工作。

. Column "n" not found and was ignored.

iris %>%
gtsummary::tbl_summary(type = list(where(is.logical) ~ "categorical"),
                       missing_text = 'Missing',
                       missing = 'ifany') %>%
gtsummary::add_n(statistic = "{N_nonmiss}", col_label = "**N responses**") %>%
gtsummary::add_n(statistic = "{N_miss}", col_label = "**Missing**")

您可以用响应 N 和统计信息制作两个表,然后制作一个缺少 N 的表,然后使用tbl_merge()将它们组合起来。

library(gtsummary)
library(dplyr)
t1 <- iris %>%
  gtsummary::tbl_summary(type = list(where(is.logical) ~ "categorical"),
                         missing_text = 'Missing',
                         missing = 'ifany') %>%
  gtsummary::add_n(statistic = "{N_nonmiss}", 
                   col_label = "**N responses**")

t2 <- iris %>%
  gtsummary::tbl_summary(type = list(where(is.logical) ~ "categorical"),
                         missing_text = 'Missing',
                         missing = 'ifany') %>%
  gtsummary::add_n(statistic = "{N_miss}", col_label = "**Missing**") %>% 
  gtsummary::modify_column_hide(stat_0)

gtsummary::tbl_merge(list(t1,t2), tab_spanner = FALSE)
①如果本文未解决您的问题,请点击查看与本文相关的问题
②如果本文未解决您的问题,请向程序员专用AI小助手提问
暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM