drop_undeclare: Drop information / undeclare labelled objects

drop_undeclareR Documentation

Drop information / undeclare labelled objects

Description

A function to obtain a version of the object with all information about declared missing values, dropped

Usage

undeclare(x, drop = FALSE, ...)

drop_na(x, drop_labels = TRUE)

Arguments

x

A labelled object with declared missing values

drop

Logical, drop all attributes

...

Other internal arguments

drop_labels

Logical, drop the labels for the declared missing values

Details

The function undeclare() replaces the NA entries into their original numeric values, and drops all attributes related to missing values: na_values, na_range and na_index, and it preserves the labels referring to the missing values.

The result can be a regular vector (dropping all attributes, including the class "declared") by activating the argument drop.

Function drop_na() transforms the declared missing values in regular empty NAs, and the labels referring to the missing values are deleted by default.

Function drop() deletes all attributes.

Value

A declared labelled object.

See Also

Other labelling functions: labels(), measurement()

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

undeclare(x)

drop_na(x)

drop(x)

undeclare(x, drop = TRUE)

# similar to:
drop(undeclare(x))

declared documentation built on Sept. 11, 2024, 5:31 p.m.