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

count does not use current group_by (unintuitive) #1703

Closed
edwindj opened this issue Mar 11, 2016 · 0 comments
Closed

count does not use current group_by (unintuitive) #1703

edwindj opened this issue Mar 11, 2016 · 0 comments
Labels
Milestone

Comments

@edwindj
Copy link
Contributor

@edwindj edwindj commented Mar 11, 2016

Hi,

Currently count does not 'respect' group_by statements, which is not intuitive (I observed this multiple times when training novice R/dplyr users).

Example:

data(diamonds, package="ggplot2")
diamonds %>% count(cut)

diamonds %>% group_by(cut) %>% count # gives total count, not group_by

# Source: local data frame [1 x 1]
#
# n
# (int)
#1 53940

diamonds %>% group_by(cut) %>% count(clarity) # gives count by clarity (but not cut)

# Source: local data frame [8 x 2]
# 
# clarity     n
# (fctr) (int)
#1      I1   741
#2     SI2  9194
#3     SI1 13065
#4     VS2 12258
# ...

I know that one way to 'fix' this is to use tally and to expand the group_by statement, however I will submit a PR in which count expands the current grouping.

edwindj added a commit to edwindj/dplyr that referenced this issue Mar 11, 2016
edwindj added a commit to edwindj/dplyr that referenced this issue Mar 11, 2016
@hadley hadley added this to the 0.5 milestone Mar 14, 2016
@hadley hadley closed this in a42dda3 Mar 14, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants