%<% | R Documentation |
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.