Skip to content

Add user_na option to zap_labels() #638

@gorcha

Description

@gorcha

Currently zap_labels() converts user missing values in labelled_spss objects to NA.

This should be controllable by the user. I think adding a user_na option like read_sav() is the best approach, where FALSE (default) converts to NA and TRUE keeps them as valid values.

library(haven)
x <- labelled_spss(1:3, na_values = 1)
# Current behaviour
zap_labels(x)
#> [1] NA  2  3

# Desired behaviour
zap_labels(x, user_na = TRUE)
#> [1] 1  2  3

Created on 2021-09-15 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions