Get the number of unique values in an input vector.

uniqlen(vec, na.rm = TRUE)

Arguments

vec

A vector of any type.

na.rm

If TRUE, remove missing values.

Value

Number of unique values.

Examples

x <- c(1, 3, 1, 1, NA, 2, 2, 3, NA, NA, 1, 3, 1) uniqlen(x)
#> [1] 3
uniqlen(x, na.rm = FALSE)
#> [1] 4
#