These optional checks report concerns without altering observations or interpreting undocumented source symbols. Supply observation keys, units, expected periods, and geographic levels explicitly. Different measures and populations require substantive review even when these checks find no issue.
Usage
nso_check_data(
data,
keys = NULL,
unit = NULL,
period = NULL,
expected_periods = NULL,
geography_level = NULL
)Arguments
- data
A data frame, preferably an original fetched result.
- keys
Character vector of columns identifying an observation.
- unit
Optional column containing units.
- period
Optional column containing period labels.
- expected_periods
Optional expected labels, compared literally.
- geography_level
Optional column containing explicit geographic levels.
Value
A tibble with check, severity, message, and n (affected rows
or values). An empty tibble means none of the requested checks found an
issue; it does not establish semantic comparability.
Examples
# Constructed records contain a duplicate key and an unresolved symbol.
observations <- data.frame(
period = c("2023", "2023"),
value = c(12, NA_real_),
value_raw = c("12", ".."),
value_status = c("observed", "symbol")
)
nso_check_data(
observations,
keys = "period",
period = "period",
expected_periods = c("2023", "2024")
)
#> # A tibble: 3 × 4
#> check severity message n
#> <chr> <chr> <chr> <int>
#> 1 duplicate_keys review Observation keys are duplicated; inspect dimen… 2
#> 2 source_symbols review Source symbols remain unresolved; numeric miss… 1
#> 3 missing_periods review Requested periods absent: 2024 1