n_unique count unique elements | R Documentation |
Simple wrapper for length(unique(.x)). If you use n_unique_(.x) then NA is ignored when counting.
n_unique(.x, ignore_na = FALSE)
n_unique_(.x, ignore_na = TRUE)
n_unique_(.x, ignore_na = TRUE)
.x |
a vector |
ignore_na |
a logical indicating whether missing values should be removed |
a single numeric vector of the same length as the data frame it is applied to.
vignette("s")
, vignette("hablar")
# Simple
n_unique(c(1, 2, 2, 3))
# Same result as above eventhough vector includes NA
n_unique_(c(1, 2, 2, 3, NA))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.