-
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
Let pick()
support NULL
#6685
Comments
By our standard rules, |
FWIW that gives library(dplyr)
df <- data.frame(x = 1)
df %>% group_by(pick())
#> Error in `group_by()`:
#> ℹ In argument: `pick()`.
#> Caused by error in `pick()`:
#> ! Must supply at least one input to `pick()`. We've declared that So It might seem obvious that library(dplyr)
df <- tibble(g = c(1, 1, 1, 2, 2), x = c(2, 3, 1, 5, 3))
df |>
reframe(y = mean(x), z = pick(everything()), .by = g)
#> # A tibble: 5 × 3
#> g y z$x $y
#> <dbl> <dbl> <dbl> <dbl>
#> 1 1 2 2 2
#> 2 1 2 3 2
#> 3 1 2 1 2
#> 4 2 4 5 4
#> 5 2 4 3 4 So in this case we have to compute the common size of the columns selected by That means that when 0 columns are selected, the common size is 0, and we end up with the above error. |
The other potential definition for "You can only I do actually like this definition. Possibly It becomes clear that However it does mean they are slightly less like macros though, because you can't replace It would be slightly complicated to implement, as we'd need a 2nd set of pick/across specific chop promises. We can't use the standard data mask because it gets modified by other expressions along the way (which can result in deletion of columns, insertion of columns, or modification of columns before |
From a user's perspective, it seems more reasonable to support picking no variables at all for these data-masking functions. |
We explicitly defined But I can look into seeing if |
In the documentation:
Therefore, it will be as expected if they both support
NULL
to fall to no grouping.Created on 2023-02-06 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: