-
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
group_by should replace existing grouping #385
Comments
I think you're probably right, and |
Thanks a lot for the fix. Looking through the diff, it seems that you've made a minor mistake when fixing the documentation: Lines 30+31 in group-by.r should be "To instead add to the existing groups use \code{add = TRUE}". |
I like this change! Actually, I somehow was not aware of the 'add' argument, so had been wrapping in as.data.frame() as a hack for chaining. |
@statsandwich there's also |
The reason I didn't use Only saying this as an aside to understand how a less-sophisticated programmer may think. Not dplyr's problem. |
I would love to regroup my data using a chained dplyr command:
The result is:
The second group_by is not replacing the first grouping, but it iw just added to it. It took me a while to realize that it needs to be
group_by(cut, add=F).
For sure this is a more a usability preference, but especially when it comes to grouped operations, it's easy to miss an incorrect grouping, so it would be imho more clear (especially for new users) to change the default of add to FALSE. Then above code could would behave as written.
In a chained operation users might think about adding add=F. However, when using unchained (line by line) scripting, many will tend to forget that they work with a group table and will get unexpected results when applying another group_by to it.
This seems related to #121 which was tagged as fixed, but I can't see how the fix works.
The text was updated successfully, but these errors were encountered: