Check if an argument is a factor
Check if an argument is a factor
checkFactor( x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, n.levels = NULL, min.levels = NULL, max.levels = NULL, unique = FALSE, names = NULL, null.ok = FALSE ) check_factor( x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, n.levels = NULL, min.levels = NULL, max.levels = NULL, unique = FALSE, names = NULL, null.ok = FALSE ) assertFactor( x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, n.levels = NULL, min.levels = NULL, max.levels = NULL, unique = FALSE, names = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL ) assert_factor( x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, n.levels = NULL, min.levels = NULL, max.levels = NULL, unique = FALSE, names = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL ) testFactor( x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, n.levels = NULL, min.levels = NULL, max.levels = NULL, unique = FALSE, names = NULL, null.ok = FALSE ) test_factor( x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, n.levels = NULL, min.levels = NULL, max.levels = NULL, unique = FALSE, names = NULL, null.ok = FALSE ) expect_factor( x, levels = NULL, ordered = NA, empty.levels.ok = TRUE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, n.levels = NULL, min.levels = NULL, max.levels = NULL, unique = FALSE, names = NULL, null.ok = FALSE, info = NULL, label = vname(x) )
x |
[any] |
levels |
[ |
ordered |
[ |
empty.levels.ok |
[ |
any.missing |
[ |
all.missing |
[ |
len |
[ |
min.len |
[ |
max.len |
[ |
n.levels |
[ |
min.levels |
[ |
max.levels |
[ |
unique |
[ |
names |
[ |
null.ok |
[ |
.var.name |
[ |
add |
[ |
info |
[character(1)] |
label |
[ |
Depending on the function prefix:
If the check is successful, the functions
assertFactor/assert_factor return
x invisibly, whereas
checkFactor/check_factor and
testFactor/test_factor return
TRUE.
If the check is not successful,
assertFactor/assert_factor
throws an error message,
testFactor/test_factor
returns FALSE,
and checkFactor returns a string with the error message.
The function expect_factor always returns an
expectation.
Other basetypes:
checkArray(),
checkAtomicVector(),
checkAtomic(),
checkCharacter(),
checkComplex(),
checkDataFrame(),
checkDate(),
checkDouble(),
checkEnvironment(),
checkFormula(),
checkFunction(),
checkIntegerish(),
checkInteger(),
checkList(),
checkLogical(),
checkMatrix(),
checkNull(),
checkNumeric(),
checkPOSIXct(),
checkRaw(),
checkVector()
x = factor("a", levels = c("a", "b"))
testFactor(x)
testFactor(x, empty.levels.ok = FALSE)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.