Check if all elements of one vector are equal, larger or smaller than those of another vector, allowing for errors in floating-point arithmetic.

verify(a, b)

a %==% b

a %>=% b

a %<=% b

Arguments

a

the first vector to be compared

b

the second vector to be compared

Value

TRUE or FALSE or NA

Details

%==% checks for (approximate) equality, %>=% tests if a is greater than or equal to b and %<=% tests the reverse. A %<% or %>% operator would be redundant (and conflict with magrittr).

Be aware that some binary operators, such as `/` take precedence, so make sure to wrap a and b in brackets where appropriate. Use verify(a, b) for a conventional prefix operator.

See also

all.equal Comparison identical

Examples

0.333333 %==% (1/3)
#> [1] FALSE
0.999999 %<=% 1
#> [1] TRUE
-1e-16 %>=% 0
#> [1] TRUE
verify(pi, 3.141592654)
#> [1] TRUE