modify_footnote2: Modify Footnotes

modify_footnote2R Documentation

Modify Footnotes

Description

Modify Footnotes

Usage

modify_footnote_header(
  x,
  footnote,
  columns,
  replace = TRUE,
  text_interpret = c("md", "html")
)

modify_footnote_body(
  x,
  footnote,
  columns,
  rows,
  replace = TRUE,
  text_interpret = c("md", "html")
)

modify_footnote_spanning_header(
  x,
  footnote,
  columns,
  level = 1L,
  replace = TRUE,
  text_interpret = c("md", "html")
)

remove_footnote_header(x, columns)

remove_footnote_body(x, columns, rows)

remove_footnote_spanning_header(x, columns, level)

Arguments

x

(gtsummary)
A gtsummary object

footnote

(string)
a string

columns

(tidy-select)
columns to add footnote.

For modify_footnote_spanning_header(), pass a single column name where the spanning header begins. If multiple column names are passed, only the first is used.

replace

(scalar logical)
Logical indicating whether to replace any existing footnotes in the specified location with the specified footnote, or whether the specified should be added to the existing footnote(s) in the header/cell. Default is to replace existing footnotes.

text_interpret

(string)
String indicates whether text will be interpreted with gt::md() or gt::html(). Must be "md" (default) or "html". Applies to tables printed with {gt}.

rows

(predicate expression)
Predicate expression to select rows in x$table_body. Review rows argument details.

level

(integer)
An integer specifying which level to place the spanning header footnote.

Value

Updated gtsummary object

Examples


# Example 1 ----------------------------------
tbl <- trial |>
  tbl_summary(by = trt, include = c(age, grade), missing = "no") |>
  modify_footnote_header(
    footnote = "All but four subjects received both treatments in a crossover design",
    columns = all_stat_cols(),
    replace = FALSE
  ) |>
  modify_footnote_body(
    footnote = "Tumor grade was assessed _before_ treatment began",
    columns = "label",
    rows = variable == "grade" & row_type == "label"
  )
tbl

# Example 2 ----------------------------------
# remove all footnotes
tbl |>
  remove_footnote_header(columns = all_stat_cols()) |>
  remove_footnote_body(columns = label, rows = variable == "grade" & row_type == "label")


gtsummary documentation built on April 3, 2025, 10:18 p.m.