
stop_not_equal() generates an error message for != assertions.
The left-hand side of the comparison.
The right-hand side of the comparison.
Additional arguments (not used yet).
A character string indicating the modifier to use for the
comparison ("", "any", or "all"). Default is NULL, which is
equivalent to "".
Logical, indicating whether missing values should be removed
before performing the comparison. Default is FALSE.
Logical, indicating whether the comparison should be actually
tested. Default is TRUE. If FALSE, the function only constructs the
error message based on the lengths of lhs and rhs, and the presence of
missing values.
A list of parameters to customize the error message. Optional
fields include msg (message(s) to display at the top), footer(message(s)
to add at the bottom), arg (name of first argument), arg2 (name of second
argument), id (error class id), mod (the modifier, see mod above),
call (the call where the error was generated).
This function always stops with an error.
x <- 1
stop_not_equal(x, 1) |> try()
#> Error in eval(expr, envir) : ! `x` must be != `1`.
#> ℹ `x` is: 1.
x <- 1:2
stop_not_equal(x, 1:2, mod = "any") |> try()
#> Error in eval(expr, envir) : ! Not any `x` is != `1:2`.
#> ℹ Must have at least one !=.
stop_not_equal(x, 1:2, mod = "all") |> try()
#> Error in eval(expr, envir) : ! Not all `x` are != `1:2`.
#> ℹ Must all be !=.