checkmate (version 1.7.2)

checkNames: 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", add = NULL, .var.name)

assert_names(x, type = "named", add = NULL, .var.name)

testNames(x, type = "named")

test_names(x, type = "named")

expect_names(x, type = "named", info = NULL, label = NULL)

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 regular names which excludes names to be NA or empty (""
add
[AssertCollection] Collection to store assertions. See AssertCollection.
.var.name
[character(1)] Name for x. Defaults to a heuristic to determine the name using deparse and substitute.
info
[character(1)] Extra information to be included in the message for the testthat reporter. See expect_that.
label
[character(1)] Same as .var.name, but passed down to expect_that.

Value

  • Depending on the function prefix: If the check is successful, the functions return TRUE. If the check is not successful, assertNamed/assert_named throws an error message, testNamed/test_named returns FALSE, and checkNamed returns a string with the error message. The function expect_named always returns an expectation.

Examples

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

Run the code above in your browser using DataCamp Workspace