| checkInteger {checkmate} | R Documentation |
Check if an argument is vector of type integer
Description
Check if an argument is vector of type integer
Usage
checkInteger(
x,
lower = -Inf,
upper = Inf,
any.missing = TRUE,
all.missing = TRUE,
len = NULL,
min.len = NULL,
max.len = NULL,
unique = FALSE,
sorted = FALSE,
names = NULL,
typed.missing = FALSE,
null.ok = FALSE
)
check_integer(
x,
lower = -Inf,
upper = Inf,
any.missing = TRUE,
all.missing = TRUE,
len = NULL,
min.len = NULL,
max.len = NULL,
unique = FALSE,
sorted = FALSE,
names = NULL,
typed.missing = FALSE,
null.ok = FALSE
)
assertInteger(
x,
lower = -Inf,
upper = Inf,
any.missing = TRUE,
all.missing = TRUE,
len = NULL,
min.len = NULL,
max.len = NULL,
unique = FALSE,
sorted = FALSE,
names = NULL,
typed.missing = FALSE,
null.ok = FALSE,
.var.name = vname(x),
add = NULL
)
assert_integer(
x,
lower = -Inf,
upper = Inf,
any.missing = TRUE,
all.missing = TRUE,
len = NULL,
min.len = NULL,
max.len = NULL,
unique = FALSE,
sorted = FALSE,
names = NULL,
typed.missing = FALSE,
null.ok = FALSE,
.var.name = vname(x),
add = NULL
)
testInteger(
x,
lower = -Inf,
upper = Inf,
any.missing = TRUE,
all.missing = TRUE,
len = NULL,
min.len = NULL,
max.len = NULL,
unique = FALSE,
sorted = FALSE,
names = NULL,
typed.missing = FALSE,
null.ok = FALSE
)
test_integer(
x,
lower = -Inf,
upper = Inf,
any.missing = TRUE,
all.missing = TRUE,
len = NULL,
min.len = NULL,
max.len = NULL,
unique = FALSE,
sorted = FALSE,
names = NULL,
typed.missing = FALSE,
null.ok = FALSE
)
expect_integer(
x,
lower = -Inf,
upper = Inf,
any.missing = TRUE,
all.missing = TRUE,
len = NULL,
min.len = NULL,
max.len = NULL,
unique = FALSE,
sorted = FALSE,
names = NULL,
typed.missing = FALSE,
null.ok = FALSE,
info = NULL,
label = vname(x)
)
Arguments
x |
[any] |
lower |
[ |
upper |
[ |
any.missing |
[ |
all.missing |
[ |
len |
[ |
min.len |
[ |
max.len |
[ |
unique |
[ |
sorted |
[ |
names |
[ |
typed.missing |
[ |
null.ok |
[ |
.var.name |
[ |
add |
[ |
info |
[ |
label |
[ |
Details
This function does not distinguish between
NA, NA_integer_, NA_real_, NA_complex_
NA_character_ and NaN.
Value
Depending on the function prefix:
If the check is successful, the functions
assertInteger/assert_integer return
x invisibly, whereas
checkInteger/check_integer and
testInteger/test_integer return
TRUE.
If the check is not successful,
assertInteger/assert_integer
throws an error message,
testInteger/test_integer
returns FALSE,
and checkInteger/check_integer
return a string with the error message.
The function expect_integer always returns an
expectation.
See Also
Other basetypes:
checkArray(),
checkAtomic(),
checkAtomicVector(),
checkCharacter(),
checkComplex(),
checkDataFrame(),
checkDate(),
checkDouble(),
checkEnvironment(),
checkFactor(),
checkFormula(),
checkFunction(),
checkIntegerish(),
checkList(),
checkLogical(),
checkMatrix(),
checkNull(),
checkNumeric(),
checkPOSIXct(),
checkRaw(),
checkVector()
Examples
testInteger(1L)
testInteger(1.)
testInteger(1:2, lower = 1, upper = 2, any.missing = FALSE)