unique_fraction: unique_fraction

Description Usage Arguments Value Examples

View source: R/unique_fraction.R

Description

fraction of unique values in a vector

Usage

1
unique_fraction(vec, na.rm = TRUE)

Arguments

vec

A vector

na.rm

Whether to consider NAs as a distinct element

Value

A numeric between 0 and 1

Examples

1
2
3
unique_fraction(c(1, 1, 2, 2, 2))
unique_fraction(c(1, 1, 2, 2, NA, 2, NA))
unique_fraction(c(1, 1, 2, 2, NA, 2, NA), na.rm = FALSE)

talegari/sidekicks documentation built on Sept. 26, 2018, 4:18 p.m.