var_labels-set: Set label attributes of all variables in a 'data.frame'

var_labels<-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
}


formatters documentation built on June 22, 2024, 9:42 a.m.