在我的 Rmarkdown 报告中,我必须在 if 语句下放置一个 gtsummary 表,这需要print()
显式打印它。但是,打印输出的脚注格式不正确。我错过了什么,我该如何解决?代码:
stats_summary_table <-
dat_wide %>%
tbl_summary(by = id,
missing = "no",
digits = list(all_continuous() ~ c(0, 0, 1, 1, 3)),
type = list(all_numeric() ~ "continuous"),
statistic = list(all_continuous() ~
"{min} ~ {max} {mean} ± {sd} [{cv}]")) %>%
modify_footnote(starts_with("stat_") ~ "Range and mean±SD [cv]")
if (n_distinct(dat_wide$id) > 1) {
stats_summary_table <- stats_summary_table %>%
add_stat(
fns = everything() ~ cal_cv,
fmt_fun = NULL,
header = "**%CV**",
footnote = "Coefficient of variation") %>%
add_p()
}
print(stats_summary_table)