Skip to content

[Bug] LOCF roll gives incorrect values when the value of the key is of very large order  #1404

@sainathadapa

Description

@sainathadapa
library(data.table)
#data.table 1.9.7  For help type ?data.table or https://github.com/Rdatatable/data.table/wiki
#The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way
options(digits=16)

seed <- data.table(x = c(0.5, 1, 1.008, 1.011), y = c('a', 'b', 'c', 'd'), key='x')
data <- data.table(x = c(0.5, 1.011), z = c('e', 'f'), key='x')
data[seed, mult = "first", roll = T]
#       x z y
#1: 0.500 e a
#2: 1.000 e b
#3: 1.008 e c
#4: 1.011 f d
seed <- data.table(x = c(0.5, 1, 1.008, 1.011) + 144557957, y = c('a', 'b', 'c', 'd'), key='x')
data <- data.table(x = c(0.5, 1.011) + 144557957, z = c('e', 'f'), key='x')
data[seed, mult = "first", roll = T]
#               x z y
#1: 144557957.500 e a
#2: 144557958.000 e b
#3: 144557958.008 e c
#4: 144557958.011 f d
seed <- data.table(x = c(0.5, 1, 1.008, 1.011) + 1445579573, y = c('a', 'b', 'c', 'd'), key='x')
data <- data.table(x = c(0.5, 1.011) + 1445579573, z = c('e', 'f'), key='x')
data[seed, mult = "first", roll = T]
#                x z y
#1: 1445579573.500 e a
#2: 1445579574.000 e b
#3: 1445579574.008 f c
#4: 1445579574.011 f d

Check the 3rd and 4th rows in the last case against the answers from the 1st and 2nd cases. 'f' value in z column should occur only in the last row for all the cases.

sessionInfo()
#R version 3.2.2 (2015-08-14)
#Platform: x86_64-pc-linux-gnu (64-bit)
#Running under: Ubuntu 14.04.3 LTS
#
#locale:
 #[1] LC_CTYPE=en_IN.UTF-8       LC_NUMERIC=C               LC_TIME=en_IN.UTF-8        #LC_COLLATE=en_IN.UTF-8     LC_MONETARY=en_IN.UTF-8    LC_MESSAGES=en_IN.UTF-8   
 #[7] LC_PAPER=en_IN.UTF-8       LC_NAME=C                  LC_ADDRESS=C               #LC_TELEPHONE=C             LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C       
#
#attached base packages:
#[1] stats     graphics  grDevices utils     datasets  methods   base     
#
#other attached packages:
#[1] data.table_1.9.7
#
#loaded via a namespace (and not attached):
#[1] tools_3.2.2  chron_2.3-47

Edit: Tested on the latest development version.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions