Intended for use in
between is equivalent to
lower<=x & x<=upper when
lower<x & y<upper when
FALSE. With a caveat that
upper are taken as unlimited bounds not
This can be changed by setting
inrange checks whether each value in
x is in between any of
the intervals provided in
between(x, lower, upper, incbounds=TRUE, NAbounds=TRUE, check=FALSE) x %between% y inrange(x, lower, upper, incbounds=TRUE) x %inrange% y
Any orderable vector, i.e., those with relevant methods for
Lower range bound. Either length 1 or same length as
Upper range bound. Either length 1 or same length as
Produce error if
non-equi joins were implemented in
v1.9.8. They extend
binary search based joins in
data.table to other binary operators
>=, <=, >, <.
inrange makes use of this new
functionality and performs a range join.
Logical vector the same length as
x with value
TRUE for those
that lie within the specified range.
Current implementation does not make use of ordered keys for
X = data.table(a=1:5, b=6:10, c=c(5:1)) X[b %between% c(7,9)] X[between(b, 7, 9)] # same as above # NEW feature in v1.9.8, vectorised between X[c %between% list(a,b)] X[between(c, a, b)] # same as above X[between(c, a, b, incbounds=FALSE)] # open interval # inrange() Y = data.table(a=c(8,3,10,7,-10), val=runif(5)) range = data.table(start = 1:5, end = 6:10) Y[a %inrange% range] Y[inrange(a, range$start, range$end)] # same as above Y[inrange(a, range$start, range$end, incbounds=FALSE)] # open interval
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.