Shows a breakdown of the different types of missing values in a variable
that was read with read_spss(), read_stata(), read_sas(), or
read_xpt() and contains tagged NAs.
Value
A data frame with one row per missing type, ordered by code like
the missing block of frequency() (system missing last, listed only
when it occurs):
- code
The original missing value code: numeric for SPSS codes (e.g., -9, -8), character for native format codes (e.g., ".a" for Stata, ".A" for SAS)
- label
The value label for this missing type (if available)
- n
Number of cases with this missing type
- prc
Percent of all cases
- tag
The internal tag character of the tagged NA
For a data frame, a first column variable names the variable. Without
any missing values the (empty) result is returned invisibly with a
message.
See also
read_spss(), read_stata(), read_sas(), read_xpt(),
untag_na(), strip_tags()
Other data-import:
read_por(),
read_sas(),
read_spss(),
read_stata(),
read_xlsx(),
read_xpt(),
strip_tags(),
untag_na()
Examples
# \donttest{
if (requireNamespace("haven", quietly = TRUE)) {
# Declare -9/-8 as distinct tagged missing types, then inspect them
x <- set_na(c(1, 2, -9, 3, -8, -9), -9, -8)
na_frequencies(x)
# code label n prc tag
# 1 -9 <NA> 2 33.33333 a
# 2 -8 <NA> 1 16.66667 b
}
#> code label n prc tag
#> 1 -9 <NA> 2 33.33333 a
#> 2 -8 <NA> 1 16.66667 b
# }
