add abbreviations to your rmarkdown doc

January 23, 2018
By

(This article was first published on Category R on Roel's R-tefacts, and kindly contributed to R-bloggers)

Today a small tip for when you write rmarkdown documents. Add a chunk on top with abbreviations.

in the first chunks you set the options and load the
packages. Next create abbreviations, you don’t have to care about the ordering, just put them down as you realize you are creating them.

The first step makes a dataframe (a tibble, rowwise), and the second step orders them.

tribble(
    ~Abbreviation, ~ Explanation,
    "CIA", "Central Intelligence Agency",
    "dplyr", "data.frame plyr, a tool for working with data in a rectangular format",
    "ABC", "The first few letters of the alphabet"
) %>%
    arrange(Abbreviation)

If you make use of many abbreviations, you might want to put them all in a dataframe and add them to your document.

Even better: add them to a package: a dataframe with all your abbreviations, a template rmarkdown document with your company logos, and perhaps some
ggplot themes to style your corporate work.

For instance: I create an enourmous collection of
obscure abbreviations in use in my company and put them all in my package. You don’t want to use them all in your document, that would be silly. You only want to explain the abbreviations that you use in the document.

library(tidyverse)
library(your_corp_package)
all_abbreviations_used <- c("CIA", "DONKLEBODY", "WUT", "SPEEDR")
abbreviations %>%
      filter(abbreviation %in% all_abbreviations_used)

tada! Simple, useful.

Do you have ideas how to expand this idea? Perhaps you could scan the text of a document and extract abbreviations?

To leave a comment for the author, please follow the link and comment on their blog: Category R on Roel's R-tefacts.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)