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

Comments

@davechilders
Copy link

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

This comment has been minimized.

Copy link
Member

commented May 16, 2016

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

@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
Projects
None yet
2 participants
You can’t perform that action at this time.