n_unique: n_unique

n_unique count unique elementsR Documentation

n_unique

Description

Simple wrapper for length(unique(.x)). If you use n_unique_(.x) then NA is ignored when counting.

Usage

n_unique(.x, ignore_na = FALSE)

n_unique_(.x, ignore_na = TRUE)

n_unique_(.x, ignore_na = TRUE)

Arguments

.x

a vector

ignore_na

a logical indicating whether missing values should be removed

Value

a single numeric vector of the same length as the data frame it is applied to.

See Also

vignette("s"), vignette("hablar")

Examples


# Simple
n_unique(c(1, 2, 2, 3))

# Same result as above eventhough vector includes NA
n_unique_(c(1, 2, 2, 3, NA))


hablar documentation built on March 31, 2023, 11:54 p.m.