-
Notifications
You must be signed in to change notification settings - Fork 420
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
complete
doesn't work well with grouped data frames.
#966
Comments
I could not find clear documentation on the complete function, especially the use of grouping variables. Current official example showed only one grouping variable. I tried |
Related to #396 |
add documentation to complete to explain current complete() behavior for grouped data. Closes tidyverse#966
Slightly more minimal reprex: library(dplyr, warn.conflicts = FALSE)
library(tidyr)
df <- tibble(
group1 = 1:2,
group2 = 3:4
)
df %>%
expand(group1, group2)
#> # A tibble: 4 × 2
#> group1 group2
#> <int> <int>
#> 1 1 3
#> 2 1 4
#> 3 2 3
#> 4 2 4
df %>%
group_by(group1, group2) %>%
expand(group1, group2)
#> # A tibble: 2 × 2
#> # Groups: group1, group2 [2]
#> group1 group2
#> <int> <int>
#> 1 1 3
#> 2 2 4 Created on 2021-12-20 by the reprex package (v2.0.1) |
This issue in particular is really a documentation issue. |
I just spent a few minutes figuring out why
complete
was generating all combination of values. This was happening because the data frame was grouped. Perhaps it would be useful to others to document this in the details section ofcomplete
.The text was updated successfully, but these errors were encountered: