[jaspDescriptives] Fix heatmap mean calculation to handle single observation per cell...#465
Open
sisyphus-jasp wants to merge 1 commit intojasp-stats:masterfrom
Open
Conversation
…rvation per cell...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes: https://github.com/jasp-stats/INTERNAL-jasp/issues/3077
Root cause
match.arg()normalized to"meanArithmetic"whileswitch()only handled"mean".NULL, thencolnames(data) <- ...crashed with "less than two dimensions".What changed
R/descriptives.Rin.descriptivesHeatmapAggregateData().match.arg()now accepts both"mean"and legacy"meanArithmetic".switch()now maps both keys tostats::aggregate(..., mean).Verification
testAll():[ FAIL 0 | WARN 4 | SKIP 2 | PASS 66 ](matches baseline).attachment/heatmap.jasp.jasp) with module reinstall: analysis status changed fromfatalErrortocomplete."mean"and"meanArithmetic".Caveats for reviewer
runAnalysis()used stale installed module until reinstall was enabled; verification was done withreinstall.modules = TRUEto ensure patched code path.Implementation Plan
Root cause
R/descriptives.R.descriptivesHeatmapAggregateData()callsmatch.arg(fun, c("identity", "meanArithmetic", "median", "mode", "length"))butswitch()handlesmean(notmeanArithmetic)."mean",match.arg()resolves to"meanArithmetic"(partial match), thenswitch()returnsNULL; nextcolnames(data) <- ...crashes with "less than two dimensions".Proposed changes
R/descriptives.R..descriptivesHeatmapAggregateData."mean"and legacy"meanArithmetic"inmatch.arg;stats::aggregate(..., mean)inswitch.horizontal,vertical,value,label).Expected test impact
median,mode,identity,lengthunchanged..jaspshould switch fromfatalErrortocomplete.Fix heatmap mean calculation to handle single observation per cell (n=1) instead of throwing an error
Attachment files available in: /workspace/attachment/
Files: heatmap.jasp.jasp
Screenshot Analysis
screenshot-1.png:
I couldn’t locate a local file named
screenshot-1.pngin/home/openclaw/resources, so I read the attached screenshot you provided in-chat.Exact error text visible in the screenshot:
What the UI shows (for reproduction):
Descriptivesactive.Resultswith sectionDescriptive Statistics.Heatmapsoutput is visible below the warning, suggesting the Descriptives heatmap feature is being used.Splitfield is present and appears empty.Transpose descriptives tableappears unchecked.Color palette (viridis)is selected.Tile heatmaps for selected variablesis enabled.Horizontal axis:yearVertical axis:monthDisplay value: checkedFor scale variables:Meanselected (circled in red in screenshot)For nominal and ordinal variables:Value itselfselectedDisplay legend: checkedWidth to height ratio of tiles:1Relative text size:1Descriptive Statisticstable behind/under the warning.Heatmapsplot labeledtempwith month labels and numeric tile values.value.State likely relevant to bug:
year,month) and a scale summary statistic (Mean), and the analysis crashes while still rendering at least part of the heatmap output.Test Results
Automated Code Review
Approved after 1 review iteration(s).