Get nicely formatted acronym definitions. Primarily intended for use in footnotes.
Usage
get_acronym_defs(
dictionary,
acronyms = NULL,
sep = "; ",
sep_last = NULL,
show_warnings = TRUE
)Arguments
- dictionary
A data dictionary object
- acronyms
NULLor a character vector of acronyms. One or more ofnames(dictionary$get_acronyms()). IfNULL, all acronyms indictionarywill be selected.- sep
character; separator for the acronyms.
- sep_last
NULLor character; the separator for the last two acronyms. IfNULL,sepwill be used instead.- show_warnings
logical; whether to display warnings.
Value
a character string of the form "acronym1 = acronym 1 description; acronym2 = acronym 2 description."
Examples
dd <- as_data_dictionary(iris)
dd$get_acronyms() # NULL
#> NULL
dd <- set_acronyms(dictionary = dd,
BP = "blood pressure",
SBP = "systolic blood pressure",
DBP = "diastolic blood pressure")
dd$get_acronyms()
#> BP DBP
#> "blood pressure" "diastolic blood pressure"
#> SBP
#> "systolic blood pressure"
get_acronym_defs(dd, acronyms = NULL) # use all acronyms (default)
#> [1] "BP = blood pressure; DBP = diastolic blood pressure; SBP = systolic blood pressure."
get_acronym_defs(dd, acronyms = c("DBP", "BP"))
#> [1] "BP = blood pressure; DBP = diastolic blood pressure."
# Attempt to select an acronym that was not set
get_acronym_defs(dd, acronyms = "FOO") # character(0L)
#> Warning: No acronyms match `names(dictionary$get_acronyms())`.
#> character(0)
