eduaguilera / eduaguilera/whep
regions_full$region_labour_mech: two cells hold a sub-region name instead of a mechanisation class
- Dominant language
- R
- Stars
- 1
- Forks
- 5
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 186
Description
Found while re-measuring the #386 census (PR #853).
`regions_full$region_labour_mech` is a mechanised / not-mechanised split. Its
vocabulary over the 272 rows is:
| value | rows |
|---|---|
| `no_mech` | 164 |
| `mech` | 85 |
| `RoW` | 1 |
| `Middle Africa` | 1 |
| `Micronesia` | 1 |
| `NA` | 20 |
Two cells hold a sub-region name rather than a mechanisation class:
| `code` | polity | `region_labour` | `region_labour_agg` | `region_labour_mech` |
|---|---|---|---|---|
| 7 | Angola (`AGO`) | `Middle Africa` | `SAA` | **`Middle Africa`** |
| 163 | Oceania Other (`ROCE`/`MNP`) | `Pacific` | `Micronesia` | **`Micronesia`** |
Each bad value is that row's own value from a neighbouring
`region_labour*` column — Angola's from `region_labour`, the Northern
Mariana Islands' from `region_labour_agg` — which is what a one-column
shift in the source spreadsheet looks like.
**Impact today: none.** `region_labour_mech` has no consumer anywhere in
`R/`, `data-raw/`, `tests/`, `vignettes/` or `inst/` (that is the #386
finding), so nothing computes on the two cells. This is a latent defect, not
a live one.
**Why it is not fixed in #853.** Whether Angola and the Northern Mariana
Islands belong in `mech` or `no_mech` is not recoverable from anything the
package ships — the column has no `@source` beyond the general "compiled
from FAOSTAT, UN M49, ILO, IEA and other international statistical sources",
and picking a class would be inventing a classification label. So PR #853
documents both cells in the `regions_full` `@format` block and pins them in
`tests/testthat/test_region_classifications.R`:
```r
test_that("region_labour_mech carries two labels from the wrong vocabulary", {
vocabulary <- c("mech", "no_mech", "RoW")
offenders <- whep::regions_full |>
dplyr::filter(
!is.na(.data$region_labour_mech),
!.data$region_labour_mech %in% vocabulary
)
testthat::expect_equal(offenders$code, c(7, 163))
...
})
```
so repairing them has to be a deliberate edit to that test rather than a
silent one.
**What closing this needs**: the source table `region_labour_mech` was
compiled from, and the class each of the two rows should carry. Then edit
`inst/extdata/harmonization/regions_full.csv`, re-run
`Rscript data-raw/harmonization_tables.R`, and update the pinned test.
Contributor guide
Assessment
This issue has not been assessed yet.