What is wrong
whep::sjos_levels is documented as ported by value from
afsetools::load_vectors(), but its ordering is reversed relative to the
source.
afsetools wraps the vector in rev(), so its realised element 1 is
"Exceedance Over":
# afsetools/R/load_vectors.R:684
assign("SJOS_levels", rev(c("Within_boundary Under", "Within_boundary Adequate",
"Within_boundary Over", "Exceedance Under", "Exceedance Adequate",
"Exceedance Over")), envir = env)
whep assigns order = 1L to "Within_boundary Under":
# data-raw/sjos_n_coefficients.R:95-116
"Within_boundary Under", 1L, "lightseagreen",
...
"Exceedance Over", 6L, "indianred3"
The colours are ported correctly — all six match SJOS_colours exactly. Only
the order differs.
Consequences
None for classification values: classify_sjos_n() builds a factor over
sjos_levels$level, and membership is unaffected. The effect is on
presentation — stacking order and legend order in any figure meant to reproduce
Global's — which is exactly where a silent inversion is hardest to notice.
Also not carried
Nourish_colours_tot (load_vectors.R:687) and Nourish_levels_tot
(:689), the "Total" variants. nourish_levels itself is correct: whep's
Over / Adequate / Under matches afsetools Nour_levels at :683.
Fix
Either reverse order to match the source, or keep whep's ordering and change
the @source note at R/datasets_sjos_n.R:109-116 so it stops implying the
ordering was inherited. The second is probably better — ascending from
"Within_boundary Under" is the more natural reading — but it should be a stated
choice rather than an accident.
Verified by reading both files; no data or network needed.
What is wrong
whep::sjos_levelsis documented as ported by value fromafsetools::load_vectors(), but its ordering is reversed relative to thesource.
afsetools wraps the vector in
rev(), so its realised element 1 is"Exceedance Over":whep assigns
order = 1Lto"Within_boundary Under":The colours are ported correctly — all six match
SJOS_coloursexactly. Onlythe order differs.
Consequences
None for classification values:
classify_sjos_n()builds a factor oversjos_levels$level, and membership is unaffected. The effect is onpresentation — stacking order and legend order in any figure meant to reproduce
Global's — which is exactly where a silent inversion is hardest to notice.
Also not carried
Nourish_colours_tot(load_vectors.R:687) andNourish_levels_tot(
:689), the "Total" variants.nourish_levelsitself is correct: whep'sOver / Adequate / Under matches afsetools
Nour_levelsat:683.Fix
Either reverse
orderto match the source, or keep whep's ordering and changethe
@sourcenote atR/datasets_sjos_n.R:109-116so it stops implying theordering was inherited. The second is probably better — ascending from
"Within_boundary Under" is the more natural reading — but it should be a stated
choice rather than an accident.
Verified by reading both files; no data or network needed.