[英]Add more than one `add_n`
Is it possible to add more than one add_n
?是否可以添加多个
add_n
? The following code returns the following warning and neither add_n
is added.以下代码返回以下警告,并且未添加任何
add_n
。 On their own both work.两者都靠自己工作。
. 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**")
You can make two table one with the response N and statistics and then one table with the missing N and use tbl_merge()
to combine them.您可以用响应 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)
问题未解决?试试以下方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.