Skip to content
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() does not preserve grouping #168

Closed
davechilders opened this issue Feb 22, 2016 · 1 comment
Closed

complete() does not preserve grouping #168

davechilders opened this issue Feb 22, 2016 · 1 comment

Comments

@davechilders
Copy link

@davechilders davechilders commented Feb 22, 2016

Consider this grouped_df:

d <- data_frame(
  g = rep(LETTERS[1:2], each = 3),
  x = c("a", "c", "a", "b", "c", "d") ,
  y = c(1, 2, 1, 2, 1, 2)
) %>% group_by(g) %>% print

Source: local data frame [6 x 3]
Groups: g [2]

      g     x     y
  (chr) (chr) (dbl)
1     A     a     1
2     A     c     2
3     A     a     1
4     B     b     2
5     B     c     1
6     B     d     2

complete() respects the grouping when creating new rows, but the result is no longer a grouped data-frame. Shouldn't complete() preserving the grouping?

d %>% complete(x, y)

Source: local data frame [11 x 3]

       g     x     y
   (chr) (chr) (dbl)
1      A     a     1
2      A     a     1
3      A     a     2
4      A     c     1
5      A     c     2
6      B     b     1
7      B     b     2
8      B     c     1
9      B     c     2
10     B     d     1
11     B     d     2

d %>% complete(x, y) %>% is.grouped_df()
[1] FALSE

@hadley
Copy link
Member

@hadley hadley commented May 16, 2016

For future reference, please don't provide session info unless requested - it just clutters up the issue.

Loading

@hadley hadley closed this in e4906fb May 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants