Skip to content

fix: fix mixture detection when Dominance contains NA - #176

Merged
vrahier merged 2 commits into
mainfrom
vrahier/fix-dominance-detection
Oct 8, 2026
Merged

vrahier merged 2 commits into
mainfrom
vrahier/fix-dominance-detection

Conversation

@vrahier

@vrahier vrahier commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Since the statistics refactor (#172), summary() with several versions can fail with:

Error: id variables not found in data: Dominance

stats_pairs() now binds all versions of a situation with bind_rows() before calling format_cropr() once. Before #172, each version was formatted on its own.

When only one version has a Dominance column on a sole crop (e.g. a previous model version giving Dominance = "0"), the bound data has Dominance = c(NA, "0"). detect_mixture() counted NA as a distinct value, so it saw two values and treated the situation as an intercrop. format_cropr() then added Dominance to the columns used to reshape the data. That column was dropped when keeping only the columns shared with the observations, which have no Dominance, so reshape2::melt() failed.

detect_mixture() now ignores NA values when counting distinct Dominance values

@vrahier vrahier self-assigned this Oct 8, 2026
@vrahier vrahier changed the title Vrahier/fix dominance detection fix: fix mixture detection when Dominance contains NA Oct 8, 2026
@vrahier
vrahier merged commit 5377b81 into main Oct 8, 2026
10 checks passed
@vrahier
vrahier deleted the vrahier/fix-dominance-detection branch October 8, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant