This is a faster and more concise equivalent of length(unique(x))

n_distinct(..., na.rm = FALSE)

## Arguments

... vectors of values if TRUE missing values don't count

## Examples

x <- sample(1:10, 1e5, rep = TRUE)
length(unique(x))
#> [1] 10n_distinct(x)
#> [1] 10