var_labels<- {formatters}R Documentation

Set label attributes of all variables in a data.frame

Description

Variable labels can be stored as the label attribute for each variable. This functions sets all non-missing (non-NA) variable labels in a data.frame.

Usage

var_labels(x) <- value

Arguments

x

(data.frame)
a data frame object.

value

(character)
a vector of new variable labels. If any values are NA, the label for that variable is removed.

Value

x with modified variable labels.

Examples

x <- iris
var_labels(x)
var_labels(x) <- paste("label for", names(iris))
var_labels(x)

if (interactive()) {
  View(x) # in RStudio data viewer labels are displayed
}


[Package formatters version 0.5.8 Index]