Fix sample.order handling for stacked grouped barplots - order by total stacked height/width #220
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.
Fixes a bug in
create.barplot()wheresample.order = 'increasing'/'decreasing'was incorrectly ordering stacked grouped barplots by the first group's values only, instead of ordering by the total stacked height/width across all groups.Problem
When creating stacked barplots with groups and using
sample.order = 'increasing'or'decreasing', the bars were ordered based only on the first group's values rather than the sum of all groups for each sample. This resulted in visually incorrect ordering that didn't match user expectations.For example, with this data:
The old logic would order by first values: A(1), C(2), D(3), B(5)
The correct logic should order by totals: C(4), D(6), B(8), A(10)
Solution
Modified the sample ordering logic in
create.barplot.Rto:stack = TRUEANDgroupsis not NULLna.rm = TRUEThe fix handles both vertical orientation (y-values) and horizontal orientation (x-values).
Changes
Testing
Added tests that verify:
sample.order = 'increasing'produces ascending totals left-to-rightsample.order = 'decreasing'produces descending totals left-to-rightFixes #48
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
cloud.r-project.org/usr/lib/R/bin/exec/R -e install.packages(c('devtools',~+~'testthat'),~+~repos='REDACTED')(dns block)esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.