Less than or Less than and equal operators that can be chained together.
Comparison operators that can be chained together into something like 0 %<% x %<% 1 instead of 0 < x \&\& x < 1.
x %<% y x %<=% y
x,y |
Values to compare |
These functions/operators allow chained inequalities. To specify that
you want the values between two values (say 0 and 1) you can use 0
%<% x %<% 1
rather than 0 < x \&\& x < 1
.
A logical vector is returned that can be used for subsetting like
<
, but the original values are included as attributes to be used
in additional comparisons.
This operator is not fully associative and has different precedence than
<
and <=
, so be careful with parentheses.
See the examples.
Greg Snow, 538280@gmail.com
x <- -3:3 -2 %<% x %<% 2 c( -2 %<% x %<% 2 ) x[ -2 %<% x %<% 2 ] x[ -2 %<=% x %<=% 2 ] x <- rnorm(100) y <- rnorm(100) x[ -1 %<% x %<% 1 ] range( x[ -1 %<% x %<% 1 ] ) cbind(x,y)[ -1 %<% x %<% y %<% 1, ] cbind(x,y)[ (-1 %<% x) %<% (y %<% 1), ] cbind(x,y)[ ((-1 %<% x) %<% y) %<% 1, ] cbind(x,y)[ -1 %<% (x %<% (y %<% 1)), ] cbind(x,y)[ -1 %<% (x %<% y) %<% 1, ] # oops 3 3
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.