-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Milestone
Description
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
´´´
Metadata
Metadata
Assignees
Labels
No labels