Set Label Attributes of All Variables in a data.frame
col_labels-set.Rd
Variable labels can be stored as a label
attribute for each variable.
This functions sets all non-missing (non-NA) variable labels in a data.frame
Usage
col_labels(x) <- value
Source
This function was taken 1-1 from formatters package, to reduce the complexity of the dependency tree.
Examples
x <- iris
col_labels(x)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> NA NA NA NA NA
col_labels(x) <- paste("label for", names(iris))
col_labels(x)
#> Sepal.Length Sepal.Width Petal.Length
#> "label for Sepal.Length" "label for Sepal.Width" "label for Petal.Length"
#> Petal.Width Species
#> "label for Petal.Width" "label for Species"
if (interactive()) {
View(x) # in RStudio data viewer labels are displayed
}