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

Does n_distinct fail with numeric variables? #384

Closed
emiliotorres opened this issue Apr 13, 2014 · 0 comments
Closed

Does n_distinct fail with numeric variables? #384

emiliotorres opened this issue Apr 13, 2014 · 0 comments
Assignees
Milestone

Comments

@emiliotorres
Copy link

@emiliotorres emiliotorres commented Apr 13, 2014

Dear Sir,
It seems to me that n_distinct() fails with numeric variables.
Best regards
Emilio

library(hflights)
library(dplyr)

## OK
x <- hflights$ArrDelay
class(x) # integer
length(unique(x)) # 464
n_distinct(x) # 464

## WRONG
x <- as.numeric(hflights$ArrDelay)
class(x) # numeric
length(unique(x)) # 464
n_distinct(x) # 4085

sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=es_ES.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=es_ES.UTF-8        LC_COLLATE=es_ES.UTF-8    
 [5] LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=es_ES.UTF-8   
 [7] LC_PAPER=es_ES.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_0.1.3  hflights_0.1

loaded via a namespace (and not attached):
[1] assertthat_0.1 Rcpp_0.11.1    tools_3.0.2 
´´´
@romainfrancois romainfrancois added this to the v0.2 milestone Apr 17, 2014
@romainfrancois romainfrancois self-assigned this Apr 17, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants