Similar to checkNamed but you can pass the names directly.
checkNames(x, type = "named", permutation.of = NULL, subset.of = NULL,
  identical.to = NULL)check_names(x, type = "named", permutation.of = NULL, subset.of = NULL,
  identical.to = NULL)
assertNames(x, type = "named", permutation.of = NULL, subset.of = NULL,
  identical.to = NULL, .var.name = vname(x), add = NULL)
assert_names(x, type = "named", permutation.of = NULL, subset.of = NULL,
  identical.to = NULL, .var.name = vname(x), add = NULL)
testNames(x, type = "named", permutation.of = NULL, subset.of = NULL,
  identical.to = NULL)
test_names(x, type = "named", permutation.of = NULL, subset.of = NULL,
  identical.to = NULL)
expect_names(x, type = "named", permutation.of = NULL, subset.of = NULL,
  identical.to = NULL, info = NULL, label = vname(x))
[character || NULL]
Names to check using rules defined via type.
[character(1)]
Type of formal check(s) to perform on the names.
“unnamed” checks x to be NULL.
“named” (default) checks x for regular names which excludes names to be NA or empty ("").
“unique” additionally tests for non-duplicated names.
“strict” checks for unique names which comply to R's variable name restrictions.
Note that for zero-length x all these name checks evaluate to TRUE.
[character]
Names provided in x must be a permutation of the set permutation.of.
Duplicated names in permutation.of are stripped out and duplicated names in x
thus lead to a failed check.
Use this argument instead of identical.to if the order of the names is not relevant.
[character]
Names provided in x must be subset of the set subset.of.
Use this argument if duplicated names are okay.
[character]
Names provided in x must be identical to the vector identical.to.
Use this argument instead of permutation.of if the order of the names is relevant.
[character(1)]
Name of the checked object to print in assertions. Defaults to
the heuristic implemented in vname.
[AssertCollection]
Collection to store assertion messages. See AssertCollection.
[character(1)]
Extra information to be included in the message for the testthat reporter.
See expect_that.
[character(1)]
Name of the checked object to print in messages. Defaults to
the heuristic implemented in vname.
Depending on the function prefix:
 If the check is successful, the functions 
 assertNamed/assert_named return 
 x invisibly, whereas
 checkNamed/check_named and 
 testNamed/test_named 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.
Other attributes: checkClass,
  checkNamed
x = 1:3
testNames(x, "unnamed")
names(x) = letters[1:3]
testNames(x, "unique")
cn = c("Species", "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")
assertNames(names(iris), permutation.of = cn)
Run the code above in your browser using DataLab