na_range_to_values: Harmonize SPSS-style missing value ranges

View source: R/na_range_to_values.R

na_range_to_valuesR Documentation

Harmonize SPSS-style missing value ranges

Description

Ensure consistency between SPSS-style missing value ranges ('na_range') and explicit missing values ('na_values') for labelled survey vectors.

Usage

na_range_to_values(x)

Arguments

x

A labelled vector created with [haven::labelled_spss()] or 'retroharmonize_labelled_spss_survey'.

Details

When both attributes are present, this function:

  • adjusts the missing range if it conflicts with existing missing values,

  • derives missing values from the range when necessary,

  • leaves non-SPSS-labelled vectors unchanged.

This harmonization is important before joining, binding, or summarizing survey data.

Value

The input vector with harmonized 'na_values' and 'na_range' attributes. If no harmonization is needed, 'x' is returned unchanged.

See Also

[labelled::na_range()], [labelled::na_values()], [as_numeric()]

Other variable label harmonization functions: label_normalize()


retroharmonize documentation built on Jan. 14, 2026, 9:08 a.m.