Learn R Programming

chk (version 0.2.0)

chk_unique: Check/Validate Unique

Description

Unique checks/validations.

Usage

chk_unique(x, incomparables = FALSE, x_name = NULL)

vld_unique(x, incomparables = FALSE)

chk_named(x, x_name = NULL)

vld_named(x)

Arguments

x

The object to check.

incomparables

A vector of values that cannot be compared. FALSE means that all values can be compared.

x_name

A string of the name of object x or NULL.

Value

The chk_ functions throw an informative error if the test fails. The vld_ functions return a flag indicating whether the test was met.

Functions

  • chk_unique: Check Unique

    Checks if unique using vld_unique().

  • vld_unique: Validate Unique

    Validates if unique using

    !anyDuplicated(x, incomparables = incomparables).

  • chk_named: Check Named

    Checks if is named using vld_named().

  • vld_named: Validate Named

    Checks if is named using

    !is.null(names(x)).

See Also

anyDuplicated()

is.null()

names()

Examples

Run this code
# NOT RUN {
# chk_unique
chk_unique(c(NA, 2))
try(chk_unique(c(NA, NA, 2)))
chk_unique(c(NA, NA, 2), incomparables = NA)

# vld_unique
vld_unique(NULL)
vld_unique(numeric(0))
vld_unique(c(NA, 2))
vld_unique(c(NA, NA, 2))
vld_unique(c(NA, NA, 2), incomparables = NA)

# chk_named
chk_named(c(x = 1))
try(chk_named(list(1)))

# vld_named
vld_named(c(x = 1))
vld_named(list(x = 1))
vld_named(c(x = 1)[-1])
vld_named(list(x = 1)[-1])
vld_named(1)
vld_named(list(1))
# }

Run the code above in your browser using DataLab