Skip to content

data.table:::forderv doesn't seem to handle cases with NaN, Inf and -Inf correctly. #3381

@arunsrinivasan

Description

@arunsrinivasan
require(data.table)
w <- c(NaN, Inf, -Inf)
x <- c(-Inf, 0, Inf)
y <- c(0, NaN)
z <- c(NaN, 0)
data.table:::forderv(w, retGrp=TRUE) # correct
# [1] 1 3 2
# attr(,"starts")
# [1] 1 2 3
# attr(,"maxgrpn")
# [1] 1
data.table:::forderv(x, retGrp=TRUE) # incorrect
# integer(0)
# attr(,"starts")
# [1] 1
# attr(,"maxgrpn")
# [1] 3
data.table:::forderv(y, retGrp=TRUE) # incorrect
# integer(0)
# attr(,"starts")
# [1] 1
# attr(,"maxgrpn")
# [1] 2
data.table:::forderv(z, retGrp=TRUE) # incorrect
# integer(0)
# attr(,"starts")
# [1] 1
# attr(,"maxgrpn")
# [1] 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions