On Thu, Sep 4, 2014 at 10:41 AM, Torbjørn Lindahl <torbjorn.lind...@gmail.com> wrote: > Not sure if this is the proper list to propose changes like this, if it > passes constructive criticism, it would like to have a %between% operator > in the R language. >
There is a between function in the data.table package. > library(data.table) > between function (x, lower, upper, incbounds = TRUE) { if (incbounds) x >= lower & x <= upper else x > lower & x < upper } and also in the tis package which works differently: > library(tis) > between function (y, x1, x2) { y <- unclass(y) x1 <- unclass(x1) x2 <- unclass(x2) small <- pmin(x1, x2) large <- pmax(x1, x2) (y >= small) & (y <= large) } In addition, SQL has a between operator > library(sqldf) > sqldf("select * from BOD where Time between 3 and 5") Time demand 1 3 19.0 2 4 16.0 3 5 15.6 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.