[datatable-help] Self-Join: Potential Bug?

Michael Smith my.r.help at gmail.com
Sat Jun 21 09:39:56 CEST 2014


I'm getting a warning when I run the following code in 1.9.2,
dev-1.9.3-master, and dev-1.9.3-issue_700 (b/c I thought it looks
similar to that issue, but it turns out it's different). In contrast, I
do not get this warning in 1.8.10.

Not sure whether this is a bug or whether I'm missing something:

X <- data.table(
  structure(list(ID = c(45063L, 45066L, 45172L), date = structure(c(14548,
14487, 14395), class = "Date"), price = c(17.56, 12.49, 10.04
)), .Names = c("ID", "date", "price"), row.names = c(NA, -3L), class =
"data.frame"),
  key = "ID,date")
X[J(unique(ID), as.Date(c("2009-05-31", "2010-05-31")))]


The data and the warning message look like this:

> X
      ID       date price
1: 45063 2009-10-31 17.56
2: 45066 2009-08-31 12.49
3: 45172 2009-05-31 10.04
> X[J(unique(ID), as.Date(c("2009-05-31", "2010-05-31")))]
      ID       date price
1: 45063 2009-05-31    NA
2: 45066 2010-05-31    NA
3: 45172 2009-05-31 10.04
Warning message:
In as.data.table.list(i) :
  Item 2 is of size 2 but maximum size is 3 (recycled leaving a
remainder of 1 items)


Thanks,
M


More information about the datatable-help mailing list