Fix guide merging when there are repeated labels #3599
Merged
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.
This is a PR to fix #3573, a bug whereby guides with repeated labels were merged incorrectly. This bug occurred because the two guides keys were merged using
merge()
, which only works when there are no duplicate values in the.label
column.Behaviour after this PR:
In the current implementation of merging, guides are only merged when they have identical
direction
,key$.label
,title
, andname
. Becausekey$.label
has to be identical for both guides, it should be safe to usecbind()
inguide_merge.guide_legend()
instead ofmerge()
. I took the opportunity to write (non-visual) tests for guide merging to make sure it didn't break anything. As always, happy to be convinced otherwise (or that this shouldn't be fixed right now).