Labelled data are similar to regular data, but with the added feature of variable labels. Variable labels are descriptive names that can be assigned to each column in the data frame. This can make it easier to understand what each column represents and to communicate your results more effectively.
Having a separate documentation for checking labels can slow down your workflow.
You will need the following packages to create and use variable labels in your data frame. If you are missing any of these, you will need to install them first.
Code
library(tidyverse) # general wranglinglibrary(labelled) # for general functions to work with labelled datalibrary(sjlabelled) # for example efc data set with variable labelslibrary(gtsummary) # to demonstrate automatic use of variable labels in summary tables library(ggeasy) # to use variable labels in ggplot
Labelling your data frame
As an example, we are going to label the popular mtcars data frame that comes with R. We use the function set_variable_labels() in the following manner to achieve this goal. Notice that the labels are strings so we put them in quotes: