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
a | the first vector to be compared |
---|---|
b | the second vector to be compared |
TRUE
or FALSE
or NA
%==%
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.
all.equal
Comparison
identical
0.333333 %==% (1/3)#> [1] FALSE0.999999 %<=% 1#> [1] TRUE-1e-16 %>=% 0#> [1] TRUEverify(pi, 3.141592654)#> [1] TRUE