Description Usage Arguments Details Value Examples
ac
formats acronyms when called inline in rmarkdown.
1 2 |
acronym |
character string matching value in Acronym column of |
acronyms |
character string containing name of acronym data frame |
p |
logical indicating if the acronym is plural |
altFrm |
logical indicating if alternate form of acronym should be used |
lngFrm |
logical indicating if long form of acronym should be used |
ac
handles inline acronyms and references a dataframe with the acronym name, alternate formatting, definition and include flag and returns a character string. Options include whether the acronym usage is singular or plural and whether the full definition should be used. The function handles missing acronyms, checks for first time usage, and formats the return accordingly. This function is most commonly used in rmarkdown documents.
The acronyms
data frame must contain the following columns:
Acronym = (character) name of acronym
Alternate = (character) alternate formatting for use when the acronym uses special characters or other formatting such as super/subscripts, italics, etc.
Definition = (character) long form of acronym
Include = (logical) flag indicating if the acronym has been used in the document and must be reset to FALSE at the beginning of each render
When an acronym is used, the acronym
entry is found in acronmys
and if Include is set to FALSE
indicating first usage, the return value is the long form of the acronym followed by either the acronym name or alternate form depending on altFrm
enclosed in parentheses. acronyms$Include
is set to TRUE
. Subsequent usage of an acronym will return the acronym name or alternate form.
If acronyms
is not found or if acronyms
exists but is not a data frame or does not include the necessary columns, the function stops and issues an error. If the acronym is not found in acronyms
a warning is issued and XXXacro:Acronym Not DefinedXXX is returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Example acronyms data frame
acronyms <-
tibble::tribble(
~Acronym, ~Alternate, ~Definition,
"IMO", NA,"In My Opinion",
"PCR", NA, "Polymerase Chain Reaction",
"RNA", NA, "Ribonucleic Acid",
"H2NO3", "H~2~NO~3~", "Nitric Acid")
# Add inclusion flag
acronyms$Include <- FALSE
# Alphabetize acronyms for ease of reading
acronyms <- acronyms[order(acronyms$Acronym),]
# inline usage
ac(acronym = "IMO", acronyms = "acronyms", p = FALSE, altFrm = FALSE, lngFrm = FALSE)
# or simply
ac("IMO")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.