checkList {checkmate} | R Documentation |
Check if an argument is a list
checkList(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) check_list(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) assertList(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL) assert_list(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL) testList(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) test_list(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE) expect_list(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL, null.ok = FALSE, info = NULL, label = vname(x))
x |
[any] |
types |
[ |
any.missing |
[ |
all.missing |
[ |
len |
[ |
min.len |
[ |
max.len |
[ |
unique |
[ |
names |
[ |
null.ok |
[ |
.var.name |
[ |
add |
[ |
info |
[character(1)] |
label |
[ |
... |
[any] |
Depending on the function prefix:
If the check is successful, the functions
assertList
/assert_list
return
x
invisibly, whereas
checkList
/check_list
and
testList
/test_list
return
TRUE
.
If the check is not successful,
assertList
/assert_list
throws an error message,
testList
/test_list
returns FALSE
,
and checkList
returns a string with the error message.
The function expect_list
always returns an
expectation
.
The test for uniqueness does differentiate between the different NA types in R.
This is require to be consistent with unique
while checking
scalar missing values. Also see the example.
Other basetypes: checkArray
,
checkAtomicVector
,
checkAtomic
, checkCharacter
,
checkComplex
, checkDataFrame
,
checkDate
, checkEnvironment
,
checkFactor
, checkFunction
,
checkIntegerish
,
checkInteger
, checkLogical
,
checkMatrix
, checkNull
,
checkNumeric
, checkVector
testList(list()) testList(as.list(iris), types = c("numeric", "factor")) # Uniqueness differentiates between different NA types: testList(list(NA, NA), unique = TRUE) testList(list(NA, NA_real_), unique = TRUE)