As per data.table
ver 1.8.8 %between%
is defined as follow:
> `%between%`
function (x, y)
between(x, y[1], y[2], incbounds = TRUE)
<bytecode: 0x0000000050912810>
<environment: namespace:data.table>
I thought that, with this tiny change, this function would be vectorised,
function (x, y)
between(x, y[[1]], y[[2]], incbounds = TRUE)
like between
s <- c(2, 5)
d <- c(7, 9)
> between(3, s, d)
[1] TRUE FALSE
The idea came from having a list with two vectors, which suggested me this possible usage:
`between2%` <- function(x, lst) between(x, lst[[1]], lst[[2]], incbounds = TRUE)
> 3%between%c(s,d)
[1] TRUE
> 3%between2%list(s,d)
[1] TRUE FALSE
My question is: if I replaced %between%
would any functionality in data.table
package be affected? I think it shouldn't, [[
should work with atomic vector as [
does. Am I correct? thanks
> 3%between2%c(1,5)
[1] TRUE