length_unique: Length Unique

Description Usage Arguments Details Value Author(s) Examples

Description

Returns the number of unique elements. Reports if there are possible double-ups and what they might be.

Usage

1
length_unique(x, verbose=TRUE)

Arguments

x

A vector to test for uniqueness.

verbose

A logical. Should a formal warning() be thrown.

Details

Counts the number of unique values in x. If the number of unique items does not equal the overall number of items then a double-up is suspected. If verbose=TRUE then a formal warning is thrown, otherwise it is up to the user to test pos_double manually.

Value

A named list containing:

lenuni

The number of unique items in x

pos_double

A logical denoting if double-ups were detected.

pos_double_names

If pos_double is TRUE, a character string denoting the names of possible double-ups. Otherwise NA

Author(s)

Daniel Pritchard and Gretchen Brownstein

Examples

1
2
3
4
5
dat <- c('Apples', 'Oranges', 'Cheese')
length_unique(dat)

dat_nonunique <- c('Apples', 'Oranges', 'Cheese', 'Apples')
length_unique(dat_nonunique)

dpritchard/dgmisc documentation built on May 15, 2019, 1:50 p.m.