R/n_unique.R
n_unique.Rd
Returns the number of unique values in the input vector
n_unique(x, to_unlist = FALSE)
input vector
boolean of whether to flatten the input with unlist(); default is FALSE
unlist()
FALSE
n_unique(c(1, 2, 3, 3, 4))#> [1] 4n_unique(c("A", "B", "C", "D", "A"))#> [1] 4n_unique(list(letters[1:5], letters[1:4]))#> [1] 2n_unique(list(letters[1:5], letters[1:4]), to_unlist = TRUE)#> [1] 5