Learn R Programming

zmisc (version 0.2.3)

ll_labelled: Create a labelled variable

Description

The labelled_light (ll) collection is a minimal implementation of core functions for creating and managing haven_labelled variables, and with minimal dependencies. These functions, prefixed with ll_ rely only on base R, and operate only on objects of type haven_labelled. All functions check internally that the variables have the correct class and the correct structure for labelled variables, satisfying the (minimal) specification inherent in the parameter documentation of the haven::labelled() function.

The constructor, ll_labelled(), creates a labelled variable satisfying that specification.

Usage

ll_labelled(x = double(), labels = NULL, label = NULL)

Value

A valid labelled variable.

Arguments

x

A vector to label. Must be either numeric (integer or double) or character.

labels

A named vector or NULL. The vector should be the same type as x. Unlike factors, labels don't need to be exhaustive: only a fraction of the values might be labelled.

label

A short, human-readable description of the vector.

See Also

Other labelled light: ll_assert_labelled(), ll_to_character(), ll_val_labels(), ll_var_label(), threadbare()