Skip to content

setDF should drop indices #4889

@OfekShilon

Description

@OfekShilon

ff2.zip

Attached is a small zip archive of a saved data.table that demonstrates a problem where sometimes the [ operator gives misleading results.

load("./ff2")   # from the path you extracted the archive to
dim(ff[symbol == "ZM" & date == 20210128])
#  [1] 0 2     <---- wrong results, this subset is not empty

One way to show the correct result:

> dim(ff[symbol == "ZM"][date == 20210128])
# [1] 98  2

Many seemingly no-ops fix the data.table state. One example:

ff[, symbol:=symbol]
dim(ff[symbol == "ZM" & date == 20210128])
# [1] 98  2

Tested on both Windows and Ubuntu, and data.table versions 1.13.6 and 1.11.8 correspondingly. (the sessionInfo below is of the windows machine)

# Output of sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] data.table_1.13.6

loaded via a namespace (and not attached):
[1] bit_4.0.4 compiler_3.6.1 tools_3.6.1 bit64_4.0.5

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