powered by
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)
Run the code above in your browser using DataLab