Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic indexing POSIXct #955

Closed
gsee opened this issue Nov 15, 2014 · 1 comment
Closed

Automatic indexing POSIXct #955

gsee opened this issue Nov 15, 2014 · 1 comment
Assignees
Labels
Milestone

Comments

@gsee
Copy link

gsee commented Nov 15, 2014

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 
@arunsrinivasan
Copy link
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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants