This function exists in the package data.table (with the slight difference that the bounds are included), implemented as:
between <- function(x,lower,upper,incbounds=TRUE)
{
if(incbounds) x>=lower & x<=upper
else x>lower & x
It can be used as between(x,lower,upper) or x %between% c(lower, upper)