Learn R Programming

checkmate (version 1.6.1)

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", .var.name)

testNames(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 reguluar names which excludes names to be NA or emtpy (""<
.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, all functions return TRUE. If the check is not successful, assertNamed throws an error message, testNamed returns FALSE, checkNamed returns a string with the error message. The function expect_named will return 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 DataLab