Learn R Programming

summarytools (version 1.1.3)

label: Get or Set Variable or Data Frame Labels

Description

Assigns a label to a vector or data frame, or returns value stored in the object's label attribute (or NA if none exists).

Usage

label(x, all = FALSE, fallback = FALSE, simplify = FALSE)
label(x) <- value
llabel(x, all = TRUE, fallback = FALSE, simplify = FALSE)

Value

A single character vector if all = FALSE (default), or a named list if all = TRUE (named vector when using

simplify = TRUE.

Arguments

x

An R object to extract labels from.

all

Logical. When x is a data frame, setting this argument to TRUE will make the function return all variable labels. By default, its value is FALSE, so that if x is a data frame, it is the data frame's label itself that will be returned.

fallback

a logical value indicating if labels (returned values) should fallback to object name(s). Defaults to FALSE.

simplify

When x is a data frame and all = TRUE, coerce results to a vector and remove NA's. Default is FALSE.

value

String to be used as label. To clear existing labels, use NA or NULL.

Author

Dominic Comtois, dominic.comtois@gmail.com,

Details

The wrapper function llabel was named that way to avoid conflicting with base function labels.