Learn R Programming

mariposa (version 0.7.3)

na_frequencies: Frequency Table of Missing Value Types

Description

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.

Usage

na_frequencies(x)

Value

A data frame with columns:

tag

The tag character (e.g., a-z for Stata, A-Z for SAS, a-z/A-Z/0-9 for SPSS)

n

Number of cases with this missing type

code

The original missing value code: numeric SPSS codes (e.g., -9, -8) or native format codes (e.g., ".a" for Stata, ".A" for SAS)

label

The value label for this missing type (if available)

Arguments

x

A numeric vector with tagged NAs.

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

Run this code
# \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)
  #   tag n code label
  # 1   a 2   -9  
  # 2   b 1   -8  
}
# }

Run the code above in your browser using DataLab