Learn R Programming

sjmisc (version 2.0.1)

remove_labels: Remove value labels from variables

Description

This function removes labels from a label attribute of a vector x, resp. from a set of vectors in a data.frame or list-object. The counterpart to this function is add_labels.

Usage

remove_labels(x, value)
remove_labels(x) <- value

Arguments

x
Variable (vector), list of variables or a data.frame where value label attributes should be removed.
value
Either a numeric vector, indicating the position of one or more label attributes that should be removed (see get_labels to retrieve a vector's label attributes); a character vector with names of label attributes that should be removed; or a tagged_na to remove the labels from specific NA values.

Value

x with removed value labels.

See Also

set_labels to add value labels, replacing the existing ones; add_labels to add new labels to a vector.

Examples

Run this code
data(efc)
get_labels(efc$e42dep)

x <- remove_labels(efc$e42dep, 2)
get_labels(x, include.values = "p")

x <- remove_labels(efc$e42dep, "independent")
get_labels(x, include.values = "p")

library(haven)
x <- labelled(c(1:3, tagged_na("a", "c", "z"), 4:1),
              c("Agreement" = 1, "Disagreement" = 4, "First" = tagged_na("c"),
                "Refused" = tagged_na("a"), "Not home" = tagged_na("z")))
# get current NA values
get_na(x)
get_na(remove_labels(x, tagged_na("c")))


Run the code above in your browser using DataLab