An argument x is a numerical range if and only if (all conditions must be met):
Is an object of type: integer or double.
Is a vector or length two such that the value of the first number is not
less than the second number. Equalness is allowed if and only if unique flag
is set to TRUE.
Lower bound of the interval is greater than or equal to lower and
upper bound of the interval is less than or equal to upper.
It contains only finite (given that finite is TRUE) and non-missing values.
check_range(x, lower = -Inf, upper = Inf, finite = FALSE, unique = TRUE)assert_range(
x,
lower = -Inf,
upper = Inf,
finite = FALSE,
unique = TRUE,
.var.name = checkmate::vname(x),
add = NULL
)
test_range(x, lower = -Inf, upper = Inf, finite = FALSE, unique = TRUE)
expect_range(
x,
lower = -Inf,
upper = Inf,
finite = FALSE,
unique = TRUE,
info = NULL,
label = vname(x)
)
TRUE if successful, otherwise a string with the error message.
[any]
Object to check.
[numeric(1)]
Lower value all elements of x must be greater than or equal to.
[numeric(1)]
Upper value all elements of x must be lower than or equal to.
[logical(1)]
Check for only finite values? Default is FALSE.
[logical(1)]
Must all values be unique? Default is FALSE.
[character(1)]
Name of the checked object to print in assertions. Defaults to
the heuristic implemented in vname.
[AssertCollection]
Collection to store assertion messages. See AssertCollection.
[character(1)]
Extra information to be included in the message for the testthat reporter.
See expect_that.
[character(1)]
Name of the checked object to print in messages. Defaults to
the heuristic implemented in vname.
assertions for more details.
check_range(c(1, 5))
check_range(c(-5, 1))
check_range(c(4, 1))
check_range(c(1, 1))
check_range(c(1, 1), unique = FALSE)
check_range(1:3)
Run the code above in your browser using DataLab