Skip to content

potential issue with the between operator #3014

@peterlittlejohn

Description

@peterlittlejohn

The between operator seems to not operate as intended:

d <- data.table(A=1:10)
d[,B:=3]
d[A %between% c(B,B+1)]  ##  incorrect result since default setting includes bounds 
#    A B
# 1: 3 3
d[A %between% c(3,3+1)]  ## correct result when using same notation with hard-coded bounds
#    A B
# 1: 3 3
# 2: 4 3
d[between(A,B,B+1)]      ## correct result when using different notation
#    A B
# 1: 3 3
# 2: 4 3

My R session and data.table version:

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Platform: x86_64-redhat-linux-gnu (64-bit)
> library(data.table)
data.table 1.11.2

Also tried:

 R version 3.5.1 (2018-07-02) -- "Feather Spray"
 Platform: x86_64-w64-mingw32/x64 (64-bit)
> library(data.table)
data.table 1.11.5 IN DEVELOPMENT built 2018-08-16 23:02:55 UTC; root  Latest news: r-datatable.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions