lt_footnote: Add a footnote

View source: R/tab.R

lt_footnoteR Documentation

Add a footnote

Description

Attaches a footnote text to a table region. Footnotes are numbered automatically in the order they are added (de-duplicated by text).

Usage

lt_footnote(x, text, where, columns = NULL, rows = NULL, match = NULL)

Arguments

x

An lt() object.

text

Footnote text.

where

One of 'title', 'subtitle', 'column', 'spanner', 'group', or 'body'.

columns

Character names, integer positions, or a one-sided formula (for 'column' or 'body'); predicate formulas such as ~ endsWith(., "_time") are also allowed (see lt_align()). For 'group' with match = "starts_with", a single prefix string.

rows

Integer vector of 1-based row indices (for 'body'; NULL means all rows).

match

For where = "group": one of "exact" (default), "starts_with", or "all".

Value

x with the footnote recorded.

Examples

lt(head(mtcars)) |>
  lt_footnote("Source: 1974 Motor Trend US magazine.", "title")
# raw HTML footnote (wrap in I())
lt(head(mtcars)) |>
  lt_footnote(I("See <a href='#'>docs</a>."), "title")

# a footnote for each of the six locations
d = data.frame(
  Arm   = c("Treatment", "Treatment", "Control", "Control"),
  Stat  = c("n", "Mean", "n", "Mean"),
  Value = c(31, 6.8, 30, 4.2),
  SE    = c(NA, 0.42, NA, 0.38)
)
lt(d) |>
  lt_group(~ Arm) |>
  lt_header(title = "Study Results", subtitle = "Two arms") |>
  lt_spanner(Summary ~ Value + SE) |>
  lt_footnote("Source: simulated trial data.", "title") |>
  lt_footnote("Intention-to-treat population.", "subtitle") |>
  lt_footnote("Standard error of the mean.", "column", "SE") |>
  lt_footnote("Per-arm summary statistics.", "spanner", "Summary") |>
  lt_footnote("Received active drug.", "group", "Treatment") |>
  lt_footnote("SE undefined for counts.", "body", "SE", rows = c(1, 3))

lt documentation built on Oct. 17, 2026, 9:06 a.m.