Skip to content

Automatic indexing POSIXct #955

Closed
Closed

Description

@gsee

I get an error when I try to subset a .POSIXct column when auto indexing is turned on.

library(data.table)
#data.table 1.9.5  For help type: ?data.table
#*** NB: by=.EACHI is now explicit. See README to restore previous behaviour.

options(datatable.auto.index=FALSE)  # Have to turn off to avoid error.
DT <- data.table(Time=.POSIXct(0, tz="UTC")+0:1, Value=1:2)
DT[Time==Time[1]]
#         Time Value
#1: 1970-01-01     1
DT[Time==.POSIXct(0, tz="UTC")]
#         Time Value
#1: 1970-01-01     1

options(datatable.auto.index=TRUE)
DT[Time==Time[1]]
#Error in UseMethod("as.data.table") : 
#  no applicable method for 'as.data.table' applied to an object of class "c('POSIXct', 'POSIXt')"
DT[Time==.POSIXct(0, tz="UTC")]
#Error in UseMethod("as.data.table") : 
#  no applicable method for 'as.data.table' applied to an object of class "c('POSIXct', 'POSIXt')"

sessionInfo()
#R version 3.1.1 (2014-07-10)
#Platform: x86_64-pc-linux-gnu (64-bit)
#
#locale:
#  [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C            LC_COLLATE=C        
#[5] LC_MONETARY=C        LC_MESSAGES=C        LC_PAPER=C           LC_NAME=C           
#[9] LC_ADDRESS=C         LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 
#
#attached base packages:
#  [1] stats     graphics  grDevices utils     datasets  methods   base     
#
#other attached packages:
#  [1] data.table_1.9.5
#
#loaded via a namespace (and not attached):
#  [1] chron_2.3-45 tools_3.1.1 

Activity

  1. added this to the v1.9.8 milestone on Nov 16, 2014
  2. modified the milestones: v1.9.6, v1.9.8 on Jan 12, 2015
  3. arunsrinivasan commented on Feb 8, 2015

    @arunsrinivasan
    Member

    Jan's PR for #969 fixes this. Will add tests and close.

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