-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
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)