Skip to contents

pra_score_delta() answers "did this bump move the Program-Area composite?" for one metric and one zone type. This answers the documentation question: what did this release change, per zone, across all components — so a release that altered values without altering membership (v4b's turtle merge, v5's MMPA fix) has something quantitative to show, instead of an unchanged species count.

Usage

zone_score_delta(a, b, labels = c("a", "b"))

Arguments

a, b

data frames of zone_key, metric_key, score for the earlier and later release

labels

length-2 character labels for a and b

Value

a list with by_metric (one row per shared metric: n_zones, mean_a, mean_b, mean_delta, mean_abs_delta, max_abs_delta, cor), zones_only_a/zones_only_b, metrics_only_a/metrics_only_b, and n_zones_shared

Details

Comparability is asserted, not assumed. Two releases can label a spatial unit identically and mean different things by it, so the caller must pass units that match. The specific trap: every release's subregion_key resolves to the same zone-set vintage, while the member keys are AK, AKL48, L48, USA in v1, AK, FULL, GA, PA, USA in v7 and AK, AT, GA, PA, USA in v8 — a vintage check alone would compare FULL against AT and report a delta for what is really a redefinition. So this compares only zones and metrics present on BOTH sides, and RETURNS what it had to drop rather than quietly dropping it.

Metrics move too: extrisk_reptile exists only in v1, extrisk_all only in v1–v2, and v8 replaces extrisk_other with extrisk_primary_producer. A metric on one side only is reported, never compared against nothing.

Examples

a <- data.frame(zone_key = c("GAA","GAB"), metric_key = "x", score = c(10, 20))
b <- data.frame(zone_key = c("GAA","GAB"), metric_key = "x", score = c(12, 20))
zone_score_delta(a, b)$by_metric
#>   metric_key n_zones mean_a mean_b mean_delta mean_abs_delta max_abs_delta cor
#> 1          x       2     15     16          1              1             2  NA