1

As discussed in the previous question, it seems difficult for gtsummary to include the same footnote on every page when exporting RTF using flextable; the footnote can only appear at the end of the table. I would like to ask whether gtsummary has a function similar to tt_to_flextable in rtables. It seems that tt_to_flextable can do the pagination and include the title/footnote on each page.

1 Answer 1

2

You can split a gtsummary table in various ways using the tbl_split_by_*() functions. In the example below, we are splitting a large table into a list of 14 tables. Each of the 14 tables has the titles, footnotes, source notes, etc.

# pak::pak("ddsjoberg/gtsummary")
library(gtsummary)
packageVersion("gtsummary")
#> [1] '2.3.0.9006'

tbl <- 
  cards::ADAE |> 
  tbl_hierarchical(
    variables = c(AESOC, AETERM),
    by = TRTA,
    denominator = cards::ADSL,
    id = USUBJID
  ) |> 
  modify_caption("Table 2. Adverse Events")

# this is a long table, that does not fit on a page
nrow(tbl)
#> [1] 265

# split the table with 20 rows on each page.
tbl_split <-
  tbl_split_by_rows(tbl, row_numbers = seq(20, nrow(tbl), by = 20))

# tbl_split is a list of 14 gtsummary tables, all of which have the footnotes/titles
length(tbl_split)
#> [1] 14

Created on 2025-08-22 with reprex v2.1.1

If you then take this list of tables and print them with a page break between each, you'll get the result you're after.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.