Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

remove_labels

Remove variable label, value labels and user defined missing values


Description

Use remove_var_label() to remove variable label, remove_val_labels() to remove value labels, remove_user_na() to remove user defined missing values (na_values and na_range) and remove_labels() to remove all.

Usage

remove_labels(x, user_na_to_na = FALSE, keep_var_label = FALSE)

remove_var_label(x)

remove_val_labels(x)

remove_user_na(x, user_na_to_na = FALSE)

Arguments

x

A vector or a data frame.

user_na_to_na

Convert user defined missing values into NA?

keep_var_label

Keep variable label?

Details

Be careful with remove_user_na() and remove_labels(), user defined missing values will not be automatically converted to NA, except if you specify user_na_to_na = TRUE. user_na_to_na(x) is an equivalent of remove_user_na(x, user_na_to_na = TRUE).

If you prefer to convert variables with value labels into factors, use to_factor() or use unlabelled().

Examples

x1 <- labelled_spss(1:10, c(Good = 1, Bad = 8), na_values = c(9, 10))
var_label(x1) <- "A variable"
x1

x2 <- remove_labels(x1)
x2
x3 <- remove_labels(x1, user_na_to_na = TRUE)
x3
x4 <- remove_user_na(x1, user_na_to_na = TRUE)
x4

labelled

Manipulating Labelled Data

v2.8.0
GPL-3
Authors
Joseph Larmarange [aut, cre] (<https://orcid.org/0000-0001-7097-700X>), Daniel Ludecke [ctb], Hadley Wickham [ctb], Michal Bojanowski [ctb], François Briatte [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.