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
group_by + summarize drops last grouping var #862
Comments
This is by design. After you've summarised, the last group will only have one row per group, so it's not useful to group on it. |
I see, so what if I want to maintain groups? The work around I am using (in a function) currently is:
The 2 unexpected side effects of this (and maybe it is a poor design on my part?) are:
I guess since it is by design (and won't go away) just factor that in to checks or otherwise if I want to force carrying all grouping variables after summarization? |
Then that's your problem 😛 If you give me a bit more context about what you're trying to achieve and I can suggest alternative approaches. |
touche! I'm going to let it digest a bit before I waste any of your time running down a blind alley. I'll be at your workshop in a couple weeks so if I'm still scratching your head I can pick your brain then. It's a subtle design choice on your end but I see why it makes sense. |
Tried this on two computers, with both the most recent dev version and 0.4 and bug persists.
mtcars %>% group_by(mpg, cyl) %>% summarize(mean_hp = mean(hp))
will drop cyl (but still maintains cyl column)
mtcars %>% group_by(mpg, cyl, qsec) %>% summarize(mean_hp = mean(hp))
will drop qsec (but still keep column)
The text was updated successfully, but these errors were encountered: