Demonstrating the issue of footnote printing when gt and gtsummary tables are printed from within a for() loop in an R markdown document. https://stackoverflow.com/questions/64761041/print-gtsummary-table-with-print-with-wrong-footnote-format

gtsummary test

library(gtsummary)
for(i in 1) {
  trial %>%
    select(trt, age) %>%
    tbl_summary() %>%
    print()
}
Characteristic N = 2001
Chemotherapy Treatment
Drug A 98 (49%)
Drug B 102 (51%)
Age 47 (38, 57)
Unknown 11

1

Statistics presented: n (%); Median (IQR)

gt test

library(gt)
## Warning: package 'gt' was built under R version 4.0.2
for(i in 1) {
  head(trial) %>%
    select(trt, age) %>%
    gt::gt() %>%
    gt::tab_footnote(footnote = "Statistics presented: n (%); Median (IQR)", 
                     locations = gt::cells_column_labels(columns = gt::vars(age))) %>%
    print()
}
trt age1
Drug A 23
Drug B 9
Drug A 31
Drug A NA
Drug A 51
Drug B 39

1

Statistics presented: n (%); Median (IQR)