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 comparing numeric with character #957

Closed
gsee opened this issue Nov 17, 2014 · 0 comments
Closed

Automatic indexing comparing numeric with character #957

gsee opened this issue Nov 17, 2014 · 0 comments
Assignees
Labels
Milestone

Comments

@gsee
Copy link

gsee commented Nov 17, 2014

With auto.index=TRUE, attempting to compare numeric with character in the i expression throws an error.

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.

op <- options(datatable.auto.index=FALSE) # to avoid error and see expected results
DT <- as.data.table(BOD)

DT[Time %in% c("1", "2")]
#   Time demand
#1:    1    8.3
#2:    2   10.3

DT[, Char:=as.character(Time)]
DT[Char %in% 1:2]
#   Time demand Char
#1:    1    8.3    1
#2:    2   10.3    2

options(datatable.auto.index = TRUE)
DT[Time %in% c("1", "2")]
#Error in bmerge(i, x, leftcols, rightcols, io <- FALSE, xo, roll = 0,  :
#  typeof x.Time (double) != typeof i.V1 (character)
DT[Char %in% 1:2]
#Error in bmerge(i, x, leftcols, rightcols, io <- FALSE, xo, roll = 0,  : 
#  x.'Char' is a character column being joined to i.'V1' which is type 'integer'. Character columns must join to factor or character columns.

options(op)
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