zap_labels: Zap value labels

View source: R/zap_labels.R

zap_labelsR Documentation

Zap value labels

Description

Removes value labels, leaving unlabelled vectors as is. Use this if you want to simply drop all labels from a data frame.

Zapping labels from labelled_spss() also removes user-defined missing values by default, replacing with standard NAs. Use the user_na argument to override this behaviour.

Usage

zap_labels(x, ...)

## S3 method for class 'haven_labelled_spss'
zap_labels(x, ..., user_na = FALSE)

Arguments

x

A vector or data frame

...

Other arguments passed down to method.

user_na

If FALSE, the default, zap_labels() will convert labelled_spss() user-defined missing values to NA. If TRUE they will be treated like normal values.

See Also

zap_label() to remove variable labels.

Other zappers: zap_empty(), zap_formats(), zap_label(), zap_widths()

Examples

x1 <- labelled(1:5, c(good = 1, bad = 5))
x1
zap_labels(x1)

x2 <- labelled_spss(c(1:4, 9), c(good = 1, bad = 5), na_values = 9)
x2
zap_labels(x2)

# Keep the user defined missing values
zap_labels(x2, user_na = TRUE)

# zap_labels also works with data frames
df <- tibble::tibble(x1, x2)
df
zap_labels(df)

tidyverse/haven documentation built on Oct. 14, 2024, 8:55 a.m.