These functions check whether the input is a list that contains only list elements.
Usage
check_list_of_lists(x, len = NULL)
assert_list_of_lists(
x,
len = NULL,
.var.name = checkmate::vname(x),
add = NULL
)
test_list_of_lists(x, len = NULL)Arguments
- x
[
any]
Object to check.- len
[
integer(1)]
Exact expected length ofx.- .var.name
[
character(1)]
Name of the checked object to print in assertions. Defaults to the heuristic implemented invname.- add
[
AssertCollection]
Collection to store assertion messages. SeeAssertCollection.
Value
Same as documented in check_list.
See also
Other list helpers:
merge_lists()
Examples
L <- list(list(1), list(2), 3)
check_list_of_lists(L)
#> [1] "Check for element 3 failed: Must be of type 'list', not 'double'"
test_list_of_lists(L)
#> [1] FALSE
try(assert_list_of_lists(L))
#> Error in try(assert_list_of_lists(L)) :
#> Assertion on 'L' failed: Check for element 3 failed: Must be of type 'list', not 'double'.
