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

ajongbloets opened this issue Jul 6, 2016 · 1 comment
bug an unexpected problem or unintended behavior


Copy link

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.

Copy link

krlmlr commented Nov 7, 2016

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

@krlmlr krlmlr added the bug an unexpected problem or unintended behavior label Nov 7, 2016
@hadley hadley closed this as completed 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.
bug an unexpected problem or unintended behavior
None yet

No branches or pull requests

3 participants