Learn R Programming

mariposa (version 0.7.3)

unlabel: Remove All Label Metadata

Description

Strips all label-related attributes from variables, converting haven_labelled vectors to their base R types (numeric or character). This is useful when you need plain data without any labelling for functions or packages that do not support labelled data.

Usage

unlabel(data, ...)

Value

The data with all labelling removed. haven_labelled numeric vectors become plain double, factors remain factors (but lose their "label" attribute).

Arguments

data

A data frame, tibble, or a single vector.

...

Optional: unquoted variable names (tidyselect supported). If empty, applies to all columns.

Details

The following attributes are removed:

  • "label" (variable label)

  • "labels" (value labels)

  • "na_tag_map" (tagged NA mapping)

  • "na_tag_format" (tagged NA format)

  • "na_values", "na_range" (SPSS missing value specs)

  • "format.spss", "format.stata", "format.sas" (format info)

Tagged NAs are converted to regular NA.

See Also

strip_tags() for removing only tagged NAs, to_label() for converting to factors (preserving label info)

Other labels: copy_labels(), drop_labels(), find_var(), set_na(), to_character(), to_label(), to_labelled(), to_numeric(), val_labels(), var_label()

Examples

Run this code
# Remove all labels from the entire dataset
data_plain <- unlabel(survey_data)

# Remove labels from specific variables only
data <- unlabel(survey_data, gender, life_satisfaction)

Run the code above in your browser using DataLab