This function takes a dataframe and adds labels to columns that have registered nicknames. The labels are stored as the "label" attribute for each matching column and are visible in e.g. the Rstudio data viewer.
Examples
# Register some nickname mappings
nn_register(c(
"mpg" = "Miles per Gallon",
"hp" = "Horsepower",
"cyl" = "Number of Cylinders"
))
# Add labels to mtcars dataframe
labeled_mtcars <- nn_add_labels(mtcars)
# If you're using Rstudio, run View(labeled_mtcars)
# or check the labels manually:
attr(labeled_mtcars$mpg, "label") # "Miles per Gallon"
#> [1] "Miles per Gallon"
attr(labeled_mtcars$hp, "label") # "Horsepower"
#> [1] "Horsepower"