n_distinct: Count the number of unique values in a set of vectors

View source: R/n_distinct.R

n_distinctR Documentation

Count the number of unique values in a set of vectors

Description

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

Usage

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

Arguments

...

Vectors of values.

na.rm

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

Examples

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


nathaneastwood/poorman documentation built on Feb. 10, 2024, 1:41 p.m.