hadley / r4ds

R for data science: a book
http://r4ds.hadley.nz
Other
4.51k stars 4.19k forks source link

Tidyselect operations `!` and `-` are subtly different #1598

Closed lionel- closed 10 months ago

lionel- commented 10 months ago

Closes https://github.com/tidyverse/dplyr/issues/6959

dholstius commented 9 months ago

Here's an example of a not-so-subtle difference? The final line silently declines to return foo at all.

select(mtcars, foo = cyl)  # result omits unnamed columns
select(mtcars, foo = cyl, !cyl)  # result includes unnamed columns
select(mtcars, foo = cyl, everything(), -cyl)  # result includes all columns except cyl (and foo)