Checks: no negative/missing counts; no duplicate province-year-age rows; single-year ages (15-49) present for every province-year found in the data (the two open intervals, under15/50plus, are not required to be present since they are typically very small or zero).

validate_births_by_age(df)

Arguments

df

Output of the data element of get_ine_births_by_age().

Value

list(passed = logical, issues = named list of flagged tibbles).

Examples

# Only 3 of the 35 required single-year ages (15-49) are present here,
# so this deliberately triggers the incomplete age coverage check.
births_age_df <- tibble::tibble(
  nuts3_code = "ES611",
  province_name = "Almeria",
  year = 2020,
  age = c(20, 21, 22),
  age_group = c("20", "21", "22"),
  female = c(30, 28, 25),
  male = c(32, 29, 27),
  total = female + male
)
validate_births_by_age(births_age_df)
#> Warning: Age-of-mother births validation flagged 1 issue category.
#> $passed
#> [1] FALSE
#> 
#> $issues
#> $issues$incomplete_age_coverage
#> # A tibble: 1 × 4
#>   nuts3_code province_name  year n_ages
#>   <chr>      <chr>         <dbl>  <int>
#> 1 ES611      Almeria        2020      3
#> 
#>