gtsummary
Is it possible to add more than one add_n
? The following code returns the following warning and neither add_n
is added. 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.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.