Skip to contents
  • modify_footnote_symbol() customizes the symbols used to reference footnotes in a gtsummary table. By default, footnotes are referenced with sequential numbers (1, 2, 3, ...). This function replaces those numbers with a user-specified set of symbols, e.g. c("*", "\u2020", "\u2021") (an asterisk, dagger, and double dagger).

  • remove_footnote_symbol() resets the footnote reference marks back to the default numbering.

Usage

modify_footnote_symbol(x, symbol)

remove_footnote_symbol(x)

Arguments

x

(gtsummary)
A gtsummary object

symbol

(character)
a character vector of length 2 or greater giving the ordered symbols used to reference footnotes, e.g. c("*", "\u2020", "\u2021"). Symbols are assigned to footnotes in the order the footnotes appear in the table. When the number of footnotes exceeds the number of symbols supplied, the symbols are recycled. A length of at least 2 is required because as_gt() passes these to gt::opt_footnote_marks(), which interprets a single string as the name of a built-in mark scheme. Currently only utilized by as_gt() and as_flex_table().

Value

Updated gtsummary object

Details

The symbol sequence may also be set for all tables via the "pkgwide-chr:footnote_symbol" theme element; a value set with modify_footnote_symbol() takes precedence over the theme element.

Common footnote marks

The table below lists common footnote reference marks and the R strings used to create them. The six marks correspond to those used in gt::opt_footnote_marks(marks = "extended"). Pass the R string (e.g. "\u2020") to the symbol argument to obtain the corresponding mark.

NameUnicodeR string
asteriskU+002A"*"
daggerU+2020"\u2020"
double daggerU+2021"\u2021"
section signU+00A7"\u00A7"
double vertical lineU+2016"\u2016"
pilcrow (paragraph sign)U+00B6"\u00B6"

Examples

# use symbols (instead of numbers) to reference footnotes
trial |>
  tbl_summary(by = trt, include = c(age, grade), missing = "no") |>
  add_p() |>
  modify_footnote_symbol(symbol = c("*", "\u2020", "\u2021"))
Characteristic Drug A
N = 98
*
Drug B
N = 102
*
p-value
Age 46 (37, 60) 48 (39, 56) 0.7
Grade

0.9
    I 35 (36%) 33 (32%)
    II 32 (33%) 36 (35%)
    III 31 (32%) 33 (32%)
* Median (Q1, Q3); n (%)
Wilcoxon rank sum test; Pearson’s Chi-squared test