[R] Operator proposal: %between%

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Sep 5 09:24:46 CEST 2014

On Fri, Sep 5, 2014 at 12:28 AM, David Winsemius <dwinsemius at comcast.net> wrote:

> If you are accepting feature requests

The R issue tracker has a "wishlist" section:


 - dream on....

> I would like to see a `%btwn%` function that would accept as its second argument either a two element numeric or alpha vector or a two column matrix of with the same number of rows as the first argument. Something along these lines:
>> `%btwn%` <- function(x,y) if(!is.null(dim(y))&&dim(y)[1] == length(x) ){x >= y[,1] & x < y[,2]}else{x >= y[1] & x <y[2]}
>> 4 %btwn% c(2,6)
> [1] TRUE

The problem with wishes is that someone has to make them come true, in
this case R-core. And unlike a genie who grants your wish and then
jumps back in his bottle, R-core are nice enough to hang around in
case your wish doesn't quite go to plan. They have to keep your wish
up to date, make sure it doesn't conflict with anyone elses wishes and
so on (probably taken this analogy too far now...).

 So Duncan's unspoken subtext is "why not put this in a package and
submit it to CRAN?". And then you maintain it. Because after all, you
wrote it.

 My additional question is "Why are things like %<% hidden away inside
the TeachingDemos package?". Is it worth collating useful %operators%
into a new package?

 I can't see the point really since in about a year or two everyone
will just think A %foo% B is some kind of foo-pipe that pipes A into


More information about the R-help mailing list