Skip to contents

All abbreviations are collected, de-duplicated and sorted when the table is printed, and shown as one note below the table, e.g. "Abbreviations: CI = Confidence Interval, IQR = Interquartile Range". The note is paste0(prefix, sep1, paste(abbreviations, collapse = sep2)), and the prefix and separators persist across calls: a later call changes only the values it passes.

Usage

modify_abbreviation(
  x,
  abbreviation,
  text_interpret = c("md", "html", "none"),
  prefix = NULL,
  sep1 = NULL,
  sep2 = NULL
)

remove_abbreviation(x, abbreviation = NULL)

Arguments

x

(ltsummary)
An ltsummary object.

abbreviation

(character)
One or more abbreviations, each a string such as "IQR = Interquartile Range". In remove_abbreviation(), the default NULL removes every abbreviation.

text_interpret

(string)
How the text is interpreted: "md" (the default; the markdown subset **bold**, _italic_ and line breaks), "html" (raw HTML) or "none" (shown verbatim).

prefix

(character)
Two strings, the leading text for one abbreviation and for several, e.g. c("Key", "Keys"); c("", "") drops the leading text together with sep1. Default is NULL, which uses the theme element "modify_abbreviation-arg:prefix", or else "Abbreviation" and "Abbreviations" in the theme's language. A prefix passed here or set in the theme is used as is, not translated.

sep1

(string)
Separator between the prefix and the list. Default is NULL, which uses the theme element "modify_abbreviation-arg:sep1", or else ": ".

sep2

(string)
Separator between abbreviations. Default is NULL, which uses the theme element "modify_abbreviation-arg:sep2", or else ", ".

Value

An ltsummary object.

Examples

# Example 1 ----------------------------------
tbl <- trial |>
  tbl_summary(by = trt, include = age, type = age ~ "continuous2") |>
  modify_table_body(function(body) {
    body$label <- sub("Q1, Q3", "IQR", body$label, fixed = TRUE)
    body
  }) |>
  modify_abbreviation("IQR = Interquartile Range")
tbl
# Example 2 ---------------------------------- # several abbreviations, with a custom prefix and separator tbl |> modify_abbreviation( c("Q1 = First Quartile", "Q3 = Third Quartile"), prefix = c("Key", "Keys"), sep2 = "; " ) |> remove_abbreviation("IQR = Interquartile Range")