Skip to content

Subsetting fails with integer64 keys #1108

Closed

Description

@vspinu

With git head:

require(data.table)
require(bit64)
tdf <- data.table(id = as.integer64(1:3), a = c("a", "b", "c"), key = "id")
# str(tdf)
# Classes ‘data.table’ and 'data.frame':    3 obs. of  2 variables:
#  $ id:Class 'integer64'  num [1:3] 4.94e-324 9.88e-324 1.48e-323
#  $ a : chr  "a" "b" "c"
#  - attr(*, "sorted")= chr "id"
#  - attr(*, ".internal.selfref")=<externalptr> 
tdf[.(2)]
# Empty data.table (0 rows) of 2 cols: id,a
tdf[, id := as.numeric(id)]
setkey(tdf, id)
tdf[.(2)]
#    id a
#1:  2 b
sessionInfo()
# R version 3.1.2 (2014-10-31)
# Platform: x86_64-redhat-linux-gnu (64-bit)

# locale:
#  [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C              LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    
#  [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C                
#  [9] LC_ADDRESS=C              LC_TELEPHONE=C            LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      

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

# other attached packages:
#  [1] plotmo_2.2.1         gbm_2.1-06           lattice_0.20-29      survival_2.37-7      foreach_1.4.2       
#  [6] dplyr_0.4.1          plyr_1.8.1           Rcpp_0.11.3          lubridate_1.4.0.9000 bit64_0.9-4         
# [11] bit_1.1-12           ggplot2_1.0.0.99     data.table_1.9.5     devtools_1.7.0      

# loaded via a namespace (and not attached):
#  [1] assertthat_0.1   bitops_1.0-6     chron_2.3-45     codetools_0.2-9  colorspace_1.2-4 compiler_3.1.2  
#  [7] DBI_0.3.1        digest_0.6.8     evaluate_0.5.5   formatR_1.0      grid_3.1.2       gtable_0.1.2    
# [13] httr_0.6.1       iterators_1.0.7  knitr_1.9.1      labeling_0.3     magrittr_1.5     MASS_7.3-35     
# [19] munsell_0.4.2    proto_0.3-10     RCurl_1.95-4.5   reshape2_1.4.1   scales_0.2.4     stringr_0.6.2   
# [25] tools_3.1.2     

Activity

  1. vspinu commented on Apr 7, 2015

    @vspinu
    Author

    The problem has to do with the type. The following works:

    tdf <- data.table(id = as.integer64(1:3), a = c("a", "b", "c"), key = "id")
    > tdf <- data.table(id = as.integer64(1:3), a = c("a", "b", "c"), key = "id")
    > tdf[.(as.integer64(2))]
       id a
    1:  2 b
    

    Which makes it quite inconvenient to work with. I hope there is an easy fix for this.

  2. added this to the v1.9.6 milestone on Apr 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions