Validate that a vector has only unique values
Source:R/validation-uniqueness.R
hasOnlyDistinctValues.Rd
Validate that a vector has only unique values
Usage
hasOnlyDistinctValues(values, na.rm = TRUE)
validateHasOnlyDistinctValues(values, na.rm = TRUE)
Value
hasOnlyDistinctValues
returnsTRUE
if all values are unique.validateHasOnlyDistinctValues()
returnsNULL
if only unique values present, otherwise produces error.
Examples
hasOnlyDistinctValues(c("x", "y"))
#> [1] TRUE
hasOnlyDistinctValues(c("x", "y", "x"))
#> [1] FALSE
hasOnlyDistinctValues(c("x", NA, "y", NA), na.rm = FALSE)
#> [1] FALSE
hasOnlyDistinctValues(c("x", NA, "y", NA), na.rm = TRUE)
#> [1] TRUE
validateHasOnlyDistinctValues(c("x", "y")) # NULL
#> NULL
# validateHasOnlyDistinctValues(c("x", "y", "x")) # error