Learn R Programming

testdat (version 0.4.2)

chk-patterns: Checks: patterns

Description

Check that a vector conforms to a certain pattern.

Usage

chk_regex(x, pattern)

chk_max_length(x, len)

Value

A logical vector flagging records that have passed or failed the check.

Arguments

x

A vector to check.

pattern

A str_detect() pattern to match.

len

Maximum string length.

See Also

Checks: data frame helpers

Expectations: patterns

Other vector checks: chk-dates, chk-dummy, chk-labels, chk-text, chk-uniqueness, chk-values

Examples

Run this code

x <- c("a_1", "b_2", "c_2", NA, "NULL")
chk_regex(x, "[a-z]_[0-9]")
chk_max_length(x, 3)

Run the code above in your browser using DataLab