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

Distinct creates duplicate columns when groups are included in the distinct #2001

Closed
jjongbloets opened this issue Jul 6, 2016 · 1 comment
Closed
Labels

Comments

@jjongbloets
Copy link

@jjongbloets jjongbloets commented Jul 6, 2016

When I use distinct on a grouped data.frame and explicitly put the group columns in the distinct, then I get duplicated columns:

df <- data.frame( a = c(1,2,3), b=c(4,5,6), c=c(7,8,9))

df %>% group_by(a) %>% distinct(a,b)
# creates a data.frame with two 'a' columns

Since putting 'a' in the distinct is not necessary as the group_by already makes sure that every value in 'a' is unique, this problem is easily fixed on the user side.

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Nov 7, 2016

Thanks, confirmed. Would you like to contribute a testthat test?

@krlmlr krlmlr added the bug label Nov 7, 2016
@hadley hadley closed this in 267ebb8 Feb 26, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 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
3 participants