Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bogus difference with data.table's auto-index and secondary keys #107

@krlmlr

Description

@krlmlr

Adapted from Section 3 of https://cran.r-project.org/web/packages/data.table/vignettes/datatable-secondary-indices-and-auto-indexing.html:

library(data.table)

set.seed(1L)
dt1 = data.table(x = sample(1:2, 10, TRUE), y = runif(10L))

set.seed(1L)
dt2 = data.table(x = sample(1:2, 10, TRUE), y = runif(10L))

waldo::compare(dt1, dt2)
#> ✓ No differences

dt1[x == 1L]
#>    x         y
#> 1: 1 0.2059746
#> 2: 1 0.6870228
#> 3: 1 0.3841037
#> 4: 1 0.4976992
#> 5: 1 0.7176185
#> 6: 1 0.9919061
waldo::compare(dt1, dt2)
#> `attr(old, 'index')` is an integer vector ()
#> `attr(new, 'index')` is absent

Created on 2021-09-16 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions