{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/dplyr/issues/2115","repository_url":"https://api.github.com/repos/hadley/dplyr","labels_url":"https://api.github.com/repos/hadley/dplyr/issues/2115/labels{/name}","comments_url":"https://api.github.com/repos/hadley/dplyr/issues/2115/comments","events_url":"https://api.github.com/repos/hadley/dplyr/issues/2115/events","html_url":"https://github.com/hadley/dplyr/issues/2115","id":176033110,"number":2115,"title":"Feature request: anti_distinct ?","user":{"login":"JakeRuss","id":777651,"avatar_url":"https://avatars.githubusercontent.com/u/777651?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeRuss","html_url":"https://github.com/JakeRuss","followers_url":"https://api.github.com/users/JakeRuss/followers","following_url":"https://api.github.com/users/JakeRuss/following{/other_user}","gists_url":"https://api.github.com/users/JakeRuss/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeRuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeRuss/subscriptions","organizations_url":"https://api.github.com/users/JakeRuss/orgs","repos_url":"https://api.github.com/users/JakeRuss/repos","events_url":"https://api.github.com/users/JakeRuss/events{/privacy}","received_events_url":"https://api.github.com/users/JakeRuss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-09T15:09:39Z","updated_at":"2016-09-13T12:34:01Z","closed_at":null,"body":"We have `anti_join` that makes finding non-matches easier. I often find myself wanting to check which rows are being removed by a call to `distinct`. What about a complement to `distinct` that instead preserved the duplicates?"},"comment":{"url":"https://api.github.com/repos/hadley/dplyr/issues/comments/246666678","html_url":"https://github.com/hadley/dplyr/issues/2115#issuecomment-246666678","issue_url":"https://api.github.com/repos/hadley/dplyr/issues/2115","id":246666678,"user":{"login":"JakeRuss","id":777651,"avatar_url":"https://avatars.githubusercontent.com/u/777651?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeRuss","html_url":"https://github.com/JakeRuss","followers_url":"https://api.github.com/users/JakeRuss/followers","following_url":"https://api.github.com/users/JakeRuss/following{/other_user}","gists_url":"https://api.github.com/users/JakeRuss/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeRuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeRuss/subscriptions","organizations_url":"https://api.github.com/users/JakeRuss/orgs","repos_url":"https://api.github.com/users/JakeRuss/repos","events_url":"https://api.github.com/users/JakeRuss/events{/privacy}","received_events_url":"https://api.github.com/users/JakeRuss/received_events","type":"User","site_admin":false},"created_at":"2016-09-13T12:34:00Z","updated_at":"2016-09-13T12:34:00Z","body":"@FrankPortman Sure.\r\n\r\n```\r\nlibrary(dplyr)\r\n\r\ndata(mtcars)\r\n\r\ndf <- mtcars %>% distinct(mpg, cyl, .keep_all = TRUE)\r\n```\r\nBy calling `distinct` on `mtcars` we go from 32 rows to 27. What I'd like to do is quickly switch between distinct and anti_distinct to see either (a) the 5 rows that were dropped or (b) the 10 rows with duplicates. Ideally (a) would be the default but I could see a toogle over to behavior (b) being useful too to compare potential duplicates. You might run `anti_distinct` first, look at a third column of interest, add an `arrange` to your chain, and then switch `anti_distinct` to `distinct` to finish off the sequence.\r\n\r\nCurrently, in order to get these I would rely on \r\n```\r\na <- mtcars[duplicated(mtcars[c(\"mpg\", \"cyl\")]), ]\r\n\r\nb <- mtcars[duplicated(mtcars[c(\"mpg\", \"cyl\")]) | duplicated(mtcars[c(\"mpg\",\"cyl\")], fromLast = TRUE), ]\r\n```"}}
{"actor":{"display_login":"JakeRuss"}}