Skip to contents

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)

Arguments

x

A numeric vector with tagged NAs.

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.

Examples

if (FALSE) { # \dontrun{
# SPSS data
data <- read_spss("survey.sav")
original <- untag_na(data$satisfaction)

# Stata data with tag.na
data <- read_stata("survey.dta", tag.na = c(-9, -8, -42))
original <- untag_na(data$income)
} # }