comparisons: Enhanced comparisons

Description Usage Arguments See Also Examples

Description

These operators introduce improved NA handling, reliable floating point tests, and intervals. Specifically:

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x %==% y

x %===% y

x %>=% y

x %<=% y

x %><% y

x %>=<% y

Arguments

x

a vector

y

a vector

See Also

Other comparisons: %~=%

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 ## Greater/Less than | Equal

 c(1, NA, 3, 4)  ==  c(1, NA, 4, 3)
 #  TRUE    NA  FALSE FALSE

 c(1, NA, 3, 4) %==% c(1, NA, 4, 3)
 #  TRUE  TRUE  FALSE FALSE

 c(1, NA, 3, 4) %>=% c(1, NA, 4, 3)
 #  TRUE  TRUE FALSE  TRUE

 c(1, NA, 3, 4) %<=% c(1, NA, 4, 3)
 #  TRUE  TRUE TRUE  FALSE


 # Strict equality - a la javascript's ===
 # Only tru if the class and value of x and y are the same
x <- int(2)
y <- 2
x == y         # TRUE
x %===% y      # FALSE
x %===% int(y) # TRUE


 # NOTE parentheses surrounding expression before this operator are necessary
 # Without parentheses it would be interpreted as .1 + .1 + (.1 %~=% .3)


 #### Between ####

 # ends excluded

 2 %><% c(1, 3)
 # TRUE

 3 %><% c(1, 3)
 # FALSE

 # ends included

 2 %>=<% c(1, 3)
 # TRUE

 3 %>=<% c(1, 3)
 # TRUE

roperators documentation built on May 1, 2019, 6:27 p.m.