Given a vector of atomic type (logical, integer, numeric, complex, character) or a factor the function returns the number of different elements.

nunique(x)

Arguments

x

[atomic | factor]
A vector.

Value

A single integer value.

Note

NAs are counted as a seperate value.

Examples

x = c(1, 2, 2, 3, 2, NA, NA, 5) nunique(x) # 5
#> [1] 5