R/n_distinct.R
n_distinct.Rd
This is a faster version of length(unique(x)) that calls data.table::uniqueN().
length(unique(x))
data.table::uniqueN()
n_distinct(..., na.rm = FALSE)
vectors of values
If TRUE missing values don't count
TRUE
x <- sample(1:10, 1e5, rep = TRUE) n_distinct(x) #> [1] 10