[datatable-help] Odd behavior with [.data.table and J
Christian Hudon
chudon at planora.com
Fri Aug 3 17:34:44 CEST 2012
Hello,
I'm running into an odd behavior with data.table. Given the following
variables:
> tbl = data.table(foo=c(1,2,3), bar=c(1.1, 2.2, 3.3))
> setkey(tbl, foo)
> i = data.frame(foo=1)
... I would expect the following three ways of indexing "tbl" using "i" to
give the same result, but they don't:
> tbl[i]
foo bar
1: 1 1.1
> tbl[J(i)]
Error in `[.data.table`(tbl, J(i)) :
typeof x.foo (double) != typeof i.V1 (list)
> tbl[data.table(i)]
foo bar
1: 1 1.1
Anything I'm missing on why tbl[J(i)] wouldn't work like the other two? Or
have I hit a bug? I'm running R 2.15.1 64bit on Windows 7, with data.table
1.8.2.
Thanks,
Christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20120803/60d487fc/attachment.html>
More information about the datatable-help
mailing list