-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if_any
on zero-column selection yields TRUE
#7059
Comments
At first glance, I'm fairly certain I agree for this reasoning alone > any()
[1] FALSE
> all()
[1] TRUE |
For TDD - I think the problem is here Lines 637 to 640 in 0005f67
We unconditionally return You could create a new variable called Lines 618 to 624 in 0005f67
And then return that instead of just always returning Don't forget to update the comment here Line 637 in 0005f67
And add tests with both |
Fixes tidyverse#7059 This commit addresses the unexpected behavior of `if_any()` and `if_all()` when no columns are selected. Specifically, `if_any()` now returns `FALSE`, and `if_all()` returns `TRUE` in cases where no columns match the selection criteria. Additionally, tests have been added to ensure the correct behavior of these functions in both `filter()` and `mutate()` contexts, including the scenarios highlighted by the `reprex` example. This ensures that empty selections behave consistently with the logical expectations.
Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.
if_any(<zero-column selection>, .fns)
will produceTRUE
. This contradicts expectations from, e..g,any()
.Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.
Brief description of the problem
Created on 2024-07-26 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: