
Check for geographic columns completed for unexpected rows
Source:R/check_geog_overcompleted_cols.R
check_geog_overcompleted_cols.RdChecks that geographic columns (code, name, secondary code) are only populated for rows where the geographic_level is compatible with that column.
Arguments
- data
A data frame of the data file
- meta
A data frame of the metadata file
- verbose
logical, if TRUE prints feedback messages to console for every test, if FALSE run silently
- stop_on_error
logical, if TRUE will stop with an error if the result is "FAIL", and will throw genuine warning if result is "WARNING"
Details
Geographic data files often contain rows at multiple levels (e.g. National,
Regional, and Local authority). A lower-level row is expected to carry its
parent geography's codes — a Local authority row should have region_code
filled in because every LA sits within a region. The reverse is not true: a
Regional row should not have new_la_code filled in, because a region is
not a single LA.
The compatible_levels table inside this function encodes which
geographic_level values are allowed to have each geography's columns
populated. For most geographies this means: the level itself, plus any
lower-level geographies that are geographically nested within it (e.g.
School, Ward). RSC regions, MATs, and Sponsors are treated differently —
they do not map onto the standard regional hierarchy, so Regional columns
are not expected to be populated for those rows.
Two exceptions apply:
National columns (
country_code,country_name) are expected at every level and are never checked.School and Provider name columns — if the school or provider name is the only filter in the metadata it is treated as a label column that will be populated for all rows, so it is skipped.
See also
Other check_geog:
check_geog_country_combos(),
check_geog_eda_combos(),
check_geog_ignored_rows(),
check_geog_la_col_present(),
check_geog_la_combos(),
check_geog_lad_combos(),
check_geog_lep_combos(),
check_geog_level_completed(),
check_geog_lsip_combos(),
check_geog_na(),
check_geog_na_code(),
check_geog_other_code_dupes(),
check_geog_other_dupes(),
check_geog_pcon_combos(),
check_geog_region_col_present(),
check_geog_region_combos(),
check_geog_region_for_la(),
check_geog_region_for_lad(),
check_geog_ward_combos()
Examples
check_geog_overcompleted_cols(example_data, example_meta)
#> check result
#> 1 geog_overcompleted_cols PASS
#> message guidance_url
#> 1 All geographic columns are empty where expected. NA
check_geog_overcompleted_cols(example_data, example_meta, verbose = TRUE)
#> ✔ All geographic columns are empty where expected.
#> check result
#> 1 geog_overcompleted_cols PASS
#> message guidance_url
#> 1 All geographic columns are empty where expected. NA