Learn R Programming

mariposa (version 0.7.3)

untag_na: Convert Tagged NAs Back to Original Codes

Description

Replaces tagged NAs with their original missing value codes. Works with data imported via read_spss() (with tag_na = TRUE) or any reader that used the tag_na parameter (read_stata(), read_sas(), read_xpt()). For native Stata/SAS tagged NAs (e.g., .a, .A) that have no numeric codes to recover, use strip_tags() instead.

Usage

untag_na(x)

Value

A numeric vector where tagged NAs with numeric codes have been replaced with their original values (e.g., -9, -8, -42). System NAs (untagged) remain as NA. For native Stata/SAS tagged NAs (no numeric codes), falls back to strip_tags() behavior with a warning.

Arguments

x

A numeric vector with tagged NAs.

See Also

read_spss(), read_stata(), read_sas(), na_frequencies(), strip_tags()

Other data-import: na_frequencies(), read_por(), read_sas(), read_spss(), read_stata(), read_xlsx(), read_xpt(), strip_tags()

Examples

Run this code
# \donttest{
if (requireNamespace("haven", quietly = TRUE)) {
  # Tag -9/-8 as missing, then recover the original codes
  x <- set_na(c(1, 2, -9, 3, -8), -9, -8)
  untag_na(x)   # -9 and -8 are back
}
# }

Run the code above in your browser using DataLab