na_range_to_values: Harmonize user-defined missing value ranges

Description Usage Arguments Details Value See Also Examples

View source: R/na_range_to_values.R

Description

Harmonize the na_values attribute with na_range, if the latter is present.

Usage

1
2
3

Arguments

x

A labelled_spss or labelled_spss_survey vector

Details

na_range_to_values() tests if the function needs to be called for na_values harmonization. The na_range is often missing and less likely to cause logical problems when joining survey answers.

Value

A x with harmonized na_values and na_range attributes. If min(na_values) or max(na_values) than the left- and right-hand value of na_range, it gives a warning and adjusts the original na_range.

See Also

Other harmonization functions: collect_val_labels(), harmonize_na_values(), harmonize_values(), harmonize_waves(), label_normalize(), merge_waves()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var1 <- labelled::labelled_spss(
  x = c(1,0,1,1,0,8,9), 
  labels = c("TRUST" = 1, 
             "NOT TRUST" = 0, 
             "DON'T KNOW" = 8, 
             "INAP. HERE" = 9), 
na_range = c(8,12))
  
na_range_to_values(var1)
as_numeric(na_range_to_values(var1))
as_character(na_range_to_values(var1))

antaldaniel/retroharmonize documentation built on Aug. 15, 2020, 10:13 a.m.