It seems that data.table does not support long vectors at the moment. When I create a data.table with long vectors, it should trigger an error at creation rather than when I use it somewhere else.
> library(data.table)
> d <- data.table(x = seq(1, .Machine$integer.max + 1))
Warning message:
In setattr(value, "row.names", .set_row_names(nr)) :
NAs introduced by coercion to integer range
<simpleError in dim.data.table(obj): long vectors not supported yet: ../../src/include/Rinlinedfuns.h:138>
> d
Error in dim.data.table(x) :
long vectors not supported yet: ../../src/include/Rinlinedfuns.h:138
A less obvious example is rbindlist several data.tables each does not have long vectors but together exceeds max integer.
library(data.table)
d1 <- data.table(x = seq(1, .Machine$integer.max / 2))
d2 <- data.table(x = seq(1, .Machine$integer.max / 2))
d3 <- data.table(x = seq(1, .Machine$integer.max / 2))
d <- rbindlist(list(d1, d2, d3))
which will end up in an error:
Error in vapply(x, length, 0L) : values must be type 'integer',
but FUN(X[[1]]) result is type 'double'
If a user does not keep in mind that data.table does not support long vectors yet or R uses double to represent the length of a long vector instead of an integer, the error message can be very confusing.
It seems that data.table does not support long vectors at the moment. When I create a data.table with long vectors, it should trigger an error at creation rather than when I use it somewhere else.
A less obvious example is
rbindlistseveral data.tables each does not have long vectors but together exceeds max integer.which will end up in an error:
If a user does not keep in mind that data.table does not support long vectors yet or R uses double to represent the length of a long vector instead of an integer, the error message can be very confusing.