Labels {declared}R Documentation

Get / Declare missing values

Description

Functions to extract information about the declared variable / value labels, or to declare such values if they are present in the data.

Usage

value_labels(x, prefixed = FALSE)

value_labels(x) <- value

variable_label(x)

variable_label(x) <- value

Arguments

x

A declared vector.

prefixed

Logical, prefix labels with values.

value

Any vector of values that should be declared as missing (for value_labels) or a numeric vector of length two giving the (inclusive) extents of the range of missing values (for variable_label).

Value

value_labels() will return a named vector.

variable_label() will return a single character string.

Examples

x <- declared(c(-2, 1:5, -1),
            labels = c(Good = 1, Bad = 5, DK = -1),
            na_values = c(-1, -2),
            label = "Test variable")
x

value_labels(x)

value_labels(x) <- c(Good = 1, Bad = 5, DK = -1, NotApplicable = -2)

variable_label(x)

variable_label(x) <- "This is a proper label"

x

[Package declared version 0.13 Index]