I am definitely confused on why accessing a data.table by row index is slower than data.frame. Any suggestions how i can access each row of data.table sequentially in loop that is faster?
m = matrix(1L, nrow=100000, ncol=100)
DF = as.data.frame(m)
DT = as.data.table(m)
identical(DF[100, ], DT[100, ])
[1] FALSE
> all(DF[100, ], DT[100, ])
[1] TRUE
> system.time(for (i in 1:1000) DT[i,])
user system elapsed
5.440 0.000 5.451
R> system.time(for (i in 1:1000) DF[i,])
user system elapsed
2.757 0.000 2.784
[.data.table
does a lot more things than[.data.frame
. - Arundata.table
? You can do amazing powerful things without explicit iteration. Also, you should probably do that as a separate question. - BrodieG