Labeling Variables
install.packages("labelled") # If you need to INSTALL the package.
require(labelled)
Full vignette of the ‘labelled’ package here:
browseURL("https://cran.r-project.org/web/packages/labelled/vignettes/intro_labelled.html")

# A variable label could be specified for any vector using var_label().
var_label(df$caseid_w1) <- "SMaPP ID"

# To get the variable label, simply call var_label().
var_label(df$caseid_w1)

# Another Example:
var_label(df$UserLanguage_w1) <- "Survey Language"
var_label(df$UserLanguage_w1) 
Value Labels
# The main way to create a labelled vector of values is to use the val_labels() function. 
table(df$race_w1)
val_labels(df$race_w1) <- c('Asian'="Asian", 'Black'="Black", 
                               'Hispanic or Latino/a/x'="Hispanic or Latino/a/x",
                               'Middle Eastern or Northern African'="Middle Eastern or Northern African",
                               'Native American or Alaska Native'="Native American or Alaska Native",
                               'White' ="White", 'Prefer not to say'="Prefer not to say",
                               'Other'="Other", 'Two or more races'="Two or more races")
# To get the values labels, again simply call val_labels().
val_labels(df$race_w1)

# Another Example:
val_labels(df$UserLanguage_w1) <- c(English = "EN", Spanish = "ES")
val_labels(df$UserLanguage_w1)

# See all variables labels
look_for(df)
Saving and exporting to DTA format (STATA)
install.packages("haven")
haven::write_dta(df, "~/Downloads/DataFrame_Wave_1_LABELS.dta")
Importing Data to R & Checking if labels were saved
df <- to_labelled(haven::read_dta("~/Downloads/DataFrame_Wave_1_LABELS.dta"))
look_for(df)