checkNames {checkmate} | R Documentation |
Check names to comply to specific rules
Description
Performs various checks on character vectors, usually names.
Usage
checkNames(
x,
type = "named",
subset.of = NULL,
must.include = NULL,
permutation.of = NULL,
identical.to = NULL,
disjunct.from = NULL,
what = "names"
)
check_names(
x,
type = "named",
subset.of = NULL,
must.include = NULL,
permutation.of = NULL,
identical.to = NULL,
disjunct.from = NULL,
what = "names"
)
assertNames(
x,
type = "named",
subset.of = NULL,
must.include = NULL,
permutation.of = NULL,
identical.to = NULL,
disjunct.from = NULL,
what = "names",
.var.name = vname(x),
add = NULL
)
assert_names(
x,
type = "named",
subset.of = NULL,
must.include = NULL,
permutation.of = NULL,
identical.to = NULL,
disjunct.from = NULL,
what = "names",
.var.name = vname(x),
add = NULL
)
testNames(
x,
type = "named",
subset.of = NULL,
must.include = NULL,
permutation.of = NULL,
identical.to = NULL,
disjunct.from = NULL,
what = "names"
)
test_names(
x,
type = "named",
subset.of = NULL,
must.include = NULL,
permutation.of = NULL,
identical.to = NULL,
disjunct.from = NULL,
what = "names"
)
expect_names(
x,
type = "named",
subset.of = NULL,
must.include = NULL,
permutation.of = NULL,
identical.to = NULL,
disjunct.from = NULL,
what = "names",
info = NULL,
label = vname(x)
)
Arguments
x |
[ |
type |
[character(1)]
Note that for zero-length |
subset.of |
[ |
must.include |
[ |
permutation.of |
[ |
identical.to |
[ |
disjunct.from |
[ |
what |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
Value
Depending on the function prefix:
If the check is successful, the functions
assertNames
/assert_names
return
x
invisibly, whereas
checkNames
/check_names
and
testNames
/test_names
return
TRUE
.
If the check is not successful,
assertNames
/assert_names
throws an error message,
testNames
/test_names
returns FALSE
,
and checkNames
/check_names
return a string with the error message.
The function expect_names
always returns an
expectation
.
See Also
Other attributes:
checkClass()
,
checkMultiClass()
,
checkNamed()
Examples
x = 1:3
testNames(names(x), "unnamed")
names(x) = letters[1:3]
testNames(names(x), "unique")
cn = c("Species", "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")
assertNames(names(iris), permutation.of = cn)