Learn R Programming

chk (version 0.2.0)

chk_subset: Check/Validate Superset and Subset

Description

Checks/validates if in and has values.

Usage

chk_subset(x, values, x_name = NULL)

vld_subset(x, values)

chk_superset(x, values, x_name = NULL)

vld_superset(x, values)

Arguments

x

The object to check.

values

A vector of the permitted values.

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_subset: Check In

    Checks if all values in values using vld_subset().

  • vld_subset: Validate In

    Validates all values in values using equivalent of

    all(match(x, values, nomatch = 0) > 0)

  • chk_superset: Check Has

    Checks if includes all values using vld_superset().

  • vld_superset: Validates Has

    Validates includes all values using

    all(match(values, x, nomatch = 0) > 0)

See Also

all()

match()

Examples

Run this code
# NOT RUN {
# chk_subset
chk_subset(1, 1:10)
try(chk_subset(11, 1:10))

# vld_subset
vld_subset(numeric(0), 1:10)
vld_subset(1, 1:10)
vld_subset(11, 1:10)

# chk_superset
chk_superset(1:3, 1)
try(chk_superset(1:3, 4))

# vld_superset
vld_superset(1:3, 1)
vld_superset(1:3, 4)
vld_superset(integer(0), integer(0))
# }

Run the code above in your browser using DataLab