R/n_distinct.R

n_distinct.Rd

This is the equivalent of length(unique(x)) for multiple vectors.

length(unique(x))

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

Vectors of values.

logical(1). If TRUE missing values don't count.

logical(1)

TRUE

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