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.

Related Question Is there a function within gtsummary to add the R2, N, and F-statistic to an output table which includes multiple models? Is there a way to conduct one tailed t-test using add_p or add_difference function in tbl_summary? How to add a column of statistics for only one group in gtsummary(tbl_summary) Add a "not concerned" category in gtsummary Add Control and Cases numbers instead of add_nevent() How to add % in the head of tbl_summary add a background color to the “Overall” column in gtsummary table How to add percentage to “unknown” in gt_summary Add Percentage to Grouping Variable in gtsummary Package How to add two difference statistics in tbl_summary?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM