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". Inremove_abbreviation(), the defaultNULLremoves 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 withsep1. Default isNULL, 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 isNULL, which uses the theme element"modify_abbreviation-arg:sep1", or else": ".- sep2
(
string)
Separator between abbreviations. Default isNULL, which uses the theme element"modify_abbreviation-arg:sep2", or else", ".
See also
modify_footnote_header() and modify_source_note(); the
modifier functions article
compares footnotes, source notes and abbreviations.
Other modify and format:
add_variable_group_header(),
bold_italicize_labels_levels,
bold_p(),
modify_caption(),
modify_footnote_header(),
modify_header(),
modify_source_note(),
remove_row_type(),
separate_p_footnotes(),
sort_p()
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")