powered by
This is a faster and more concise equivalent of length(unique(x))
length(unique(x))
n_distinct(..., na.rm = FALSE)
id TRUE missing values don't count
TRUE
vectors of values
x <- sample(1:10, 1e5, rep = TRUE) length(unique(x)) n_distinct(x)
Run the code above in your browser using DataLab