powered by
Two vectors are of compatible size if and only if:
At least one vector has size 1
or both vectors are of the same size.
check_length(x, len)assert_length(x, len, .var.name = checkmate::vname(x), add = NULL)test_length(x, len)
assert_length(x, len, .var.name = checkmate::vname(x), add = NULL)
test_length(x, len)
TRUE if successful, otherwise a string with the error message.
TRUE
(any) the first vector, any object for which length() function is defined.
any
length()
(count) the length of the second vector.
count
[character(1)] Name of the checked object to print in assertions. Defaults to the heuristic implemented in vname.
character(1)
vname
[AssertCollection] Collection to store assertion messages. See AssertCollection.
AssertCollection
assertions for more details.
assertions
check_length(1:5, 1) check_length(1:5, 6) check_length(1:5, 5) check_length(10, 1) check_length(10, 9)
Run the code above in your browser using DataLab