unique_fraction.Rd
fraction of unique values in a vector
unique_fraction(vec, na.rm = TRUE)
A vector
Whether to consider NAs as a distinct element
A numeric between 0 and 1
unique_fraction(c(1, 1, 2, 2, 2))#> [1] 0.4unique_fraction(c(1, 1, 2, 2, NA, 2, NA))#> [1] 0.2857143unique_fraction(c(1, 1, 2, 2, NA, 2, NA), na.rm = FALSE)#> [1] 0.4285714