checkNames {checkmate}R Documentation

Check names to comply to specific rules

Description

Similar to checkNamed but you can pass the names directly.

Usage

checkNames(x, type = "named")

assertNames(x, type = "named", .var.name)

testNames(x, type = "named")

Arguments

x

[character || NULL]
Names to check using rules defined via type.

type

[character(1)]
Select the check(s) to perform. “unnamed” checks x to be NULL. “named” (default) checks x for reguluar names which excludes names to be NA or emtpy (""). “unique” additionally tests for non-duplicated names. “strict” checks for unique names which comply to R's variable name restrictions. Note that you can use checkSubset to check for a specific set of names.

.var.name

[character(1)]
Name for x. Defaults to a heuristic to determine the name using deparse and substitute.

Value

Depending on the function prefix: If the check is successful, all functions return TRUE. If the check is not successful, assertNamed throws an error message, testNamed returns FALSE and checkNamed returns a string with the error message.

Examples

x = 1:3
testNames(x, "unnamed")
names(x) = letters[1:3]
testNames(x, "unique")

[Package checkmate version 1.6.0 Index]