| checkList | 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 |
[ |
types |
[ |
any.missing |
[ |
all.missing |
[ |
len |
[ |
min.len |
[ |
max.len |
[ |
unique |
[ |
names |
[ |
null.ok |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
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/check_list
return a string with the error message.
The function expect_list always returns an
expectation.
Contrary to R's is.list, objects of type data.frame
and pairlist are not recognized as list.
Missingness is defined here as elements of the list being NULL, analogously to anyMissing.
The test for uniqueness does differentiate between the different NA types which are built-in in R.
This is required to be consistent with unique while checking
scalar missing values. Also see the example.
Other basetypes:
checkArray(),
checkAtomic(),
checkAtomicVector(),
checkCharacter(),
checkComplex(),
checkDataFrame(),
checkDate(),
checkDouble(),
checkEnvironment(),
checkFactor(),
checkFormula(),
checkFunction(),
checkInteger(),
checkIntegerish(),
checkLogical(),
checkMatrix(),
checkNull(),
checkNumeric(),
checkPOSIXct(),
checkRaw(),
checkVector()
testList(list())
testList(as.list(iris), types = c("numeric", "factor"))
# Missingness
testList(list(1, NA), any.missing = FALSE)
testList(list(1, NULL), any.missing = FALSE)
# Uniqueness differentiates between different NA types:
testList(list(NA, NA), unique = TRUE)
testList(list(NA, NA_real_), unique = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.