Check inequality that argument is lower/greater than a value.
Arguments
- x
Function argument that is being asserted.
- arg_inequality
Character.
lowerorgreater.- arg_equal
Logical. Default
FALSE.- arg_value
Expected argument value.
- add_msg
Is an additional message that can be printed over the standard function error message. You can:
pass the names of the arguments that failed the test by using
{x_names}in the message body (e.g. "What are the {x_names}");pass the tested value by using
{arg_value}in the message body (e.g. "I want them to be {arg_value})"pass the values of the arguments that failed the test by using
{wrong_value}in the message body (e.g. "{wrong_value} is wrong")
Value
If argument fulfills the inequality, the function returns invisible
NULL, otherwise it throws an error.
Examples
n1 <- c(1)
n2 <- c(2.5)
i1 <- 666L
if (FALSE) { # \dontrun{
check_inequality(
n1, arg_inequality = "greater", arg_equal = TRUE, arg_value = 3
)
check_inequality(
n1, arg_inequality = "greater", arg_equal = FALSE, arg_value = 3
)
check_inequality(
n2, arg_inequality = "lower", arg_equal = TRUE, arg_value = 0
)
check_inequality(
i1, arg_inequality = "lower", arg_equal = FALSE, arg_value = 666
)
check_inequality(
i1, arg_inequality = "lower", arg_equal = FALSE, arg_value = 666.1
)
} # }