tidyverse / dplyr

dplyr: A grammar of data manipulation
https://dplyr.tidyverse.org/
Other
4.78k stars 2.12k forks source link

Fix `if_any()` and `if_all()` behavior with zero-column selections #7072

Closed jrwinget closed 3 months ago

jrwinget commented 3 months ago

Fixes #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.

DavisVaughan commented 3 months ago

Thanks @jrwinget!

jrwinget commented 3 months ago

Of course - this was fun! Thanks again for your feedback!!