checkFactor | R Documentation |
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 |
[ |
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
/check_factor
return a string with the error message.
The function expect_factor
always returns an
expectation
.
Other basetypes:
checkArray()
,
checkAtomic()
,
checkAtomicVector()
,
checkCharacter()
,
checkComplex()
,
checkDataFrame()
,
checkDate()
,
checkDouble()
,
checkEnvironment()
,
checkFormula()
,
checkFunction()
,
checkInteger()
,
checkIntegerish()
,
checkList()
,
checkLogical()
,
checkMatrix()
,
checkNull()
,
checkNumeric()
,
checkPOSIXct()
,
checkRaw()
,
checkVector()
x = factor("a", levels = c("a", "b"))
testFactor(x)
testFactor(x, empty.levels.ok = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.