-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
length(unique(x)) and n_distinct(x) return different answers for some lists #2222
Comments
This is because values in list columns are compared by reference, so n_distinct() treats them as different unless they really point to the same object: a <- 1
n_distinct(list(a,a))
## [1] 1 Would you like to contribute documentation? |
Thanks for the explanation. That makes sense. I'd be happy to submit a PR On Monday, November 7, 2016, Kirill Müller <[email protected]
|
I think this is more of a bug than something we need to document |
When I originally opened the issue it was because it seemed like a bug.
Kirill's explanation of the behavior makes sense but it does seem
preferable to have it behave like the base R equivalent than to have to
explain the unexpected deviation.
On Tue, Jan 31, 2017 at 6:45 PM Hadley Wickham <[email protected]> wrote:
I think this is more of a bug than something we need to document
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2222 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AHb4QwazEidocYUzxcwAcOPltp5JPKVFks5rX8exgaJpZM4KlbbQ>
.
|
Now part of #2355 |
The documentation for
n_distinct
says that it's an "equivalent of length(unique(x))"but it gives a different answer than
length(unique(x))
ifx
is a list with multiple (identical) elements.Is this a bug or is there just a missing caveat in the doc?
The text was updated successfully, but these errors were encountered: