group_by should replace existing grouping #385
I would love to regroup my data using a chained dplyr command:
group_by(diamonds, color) %.% filter(mean(carat)>0.24) %.% group_by(cut) %.% filter(mean(depth)>60)
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
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:
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.