Evaluate compare_ard() keys and columns against both ARDs - #608
Open
malanbos wants to merge 1 commit into
Open
Conversation
.process_keys_arg() and .process_compare_arg() evaluated the tidyselect expression twice, which forced the argument on the first call, so the second call received the column positions selected from x rather than the expression. Defusing the selection first evaluates it against each ARD in turn, and lets tidyselect handle selectors combined with column names.
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.
What changes are proposed in this pull request?
compare_ard()where thekeysandcolumnsselections were resolved againstxalone and the resulting column positions re-used ony. Each selection is now evaluated against both ARDs, so ARDs holding the same columns in a different order can be compared, and selecting functions may be combined with column names, e.g.keys = c(all_ard_groups("levels"), "stat_name"). (compare_ard() column resolving #606, @malanbos).process_keys_arg()and.process_compare_arg()evaluated the tidyselect expression twice. The first evaluation forced the argument, so the second call received the column positions selected fromxrather than the expression. Defusing the selection first, withenquo(), meanscards_select()receives a quosure on both calls and the selection is made against each ARD in turn.arg_nameis now passed through as well, so an unusable selection names the argument it came from.cards_select()itself is deliberately untouched.process_selectors.Ralready calls it with defused quosures (expr = xfromenquos(...), andexpr = lhs_quo), so capturing insidecards_select()would double-capture those.Tests are added for both symptoms — comparing two ARDs whose columns are in a different order, and
keys/columnscombining selecting functions with column names. Both fail onmain(The keys columns from x and y do not match, andColumns `2` and `3` don't exist) and pass here. The fulldevtools::test()suite passes, includingprocess_selectorsandselectors.I have left
NEWS.mdalone — the bullet above is ready to copy in at merge time.Reference GitHub issue associated with pull request.
Closes #606
Pre-review Checklist (if item does not apply, mark is as complete)
usethis::pr_merge_main()devtools::test_coverage()Reviewer Checklist (if item does not apply, mark is as complete)
pkgdown::build_site(). Check the R console for errors, and review the rendered website.devtools::test_coverage()When the branch is ready to be merged:
NEWS.mdwith the changes from this pull request under the heading "# cards (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (seeNEWS.mdfor examples).