Skip to contents

Replaces registered special missing or nonresponse codes with NA only when the registry explicitly authorizes action = "set_na". This function is intentionally conservative: it does not perform global recoding.

Usage

enemdu_normalize_missing_values(
  data,
  registry = enemdu_missing_code_registry(),
  vars = NULL,
  applies_to = "analysis",
  keep_raw = TRUE,
  raw_suffix = "_raw",
  create_flags = TRUE,
  flag_suffix = "_missing_flag",
  code_suffix = "_missing_code",
  type_suffix = "_missing_type",
  overwrite_raw = FALSE,
  strict = FALSE
)

Arguments

data

A data frame.

registry

Optional missing-code registry. Defaults to package registry.

vars

Optional variables to normalize. If omitted, uses registered variables present in the data.

applies_to

Scope of rules to apply. Common values are "analysis", "income_derivation", "representativity", and "all".

keep_raw

Logical. If TRUE, creates raw backup variables before recoding.

raw_suffix

Suffix for raw backup variables.

create_flags

Logical. If TRUE, creates missing audit variables.

flag_suffix

Suffix for logical missing flags.

code_suffix

Suffix for detected code variables.

type_suffix

Suffix for detected missing-type variables.

overwrite_raw

Logical. If TRUE, overwrites existing raw backup variables.

strict

Logical. If TRUE, errors when registered variables are absent.

Value

A data frame with registered codes normalized and audit attributes.