Thank you very, very much Matthew. I think this is a very valuable (at least to me), and unique feature for more powerful calculation. A very useful application I can immediately think of is for options chains and order book modeling. It's much easier to track and model the whole option chains or order book for each time stamp or symbol, and also save a lot of replicating time stamps and symbols. <div>
<br><div class="gmail_quote">2011/10/4 Matthew Dowle <span dir="ltr"><<a href="mailto:mdowle@mdowle.plus.com">mdowle@mdowle.plus.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sun, 2011-10-02 at 15:14 +0800, Branson Owen wrote:<br>
<br>
> Oh, sorry, I was testing the syntax like:<br>
><br>
> DT = data.table(A = 1:2, B = list('a', 2i))<br>
><br>
> It didn't work, and I though this feature has not been implemented.<br>
> Thank you for pointing it out with a good example.<br>
<br>
</div>Natural to assume that should work. Now in 1.6.7 :<br>
<br>
o data.table() now accepts list columns directly rather than<br>
needing to add list columns to an existing data.table; e.g.,<br>
<br>
DT = data.table(x=1:3,y=list(4:6,3.14,matrix(1:12,3)))<br>
<br>
Thanks to Branson Owen for reminding.<br>
<br>
Accordingly, one item has been added to FAQ 2.17 (differences<br>
between data.frame and data.table) : "data.frame(list(1:2,"k",1:4))<br>
creates 3 columns, data.table creates one list column"<br>
<br>
As before, list columns can be created via grouping; e.g.,<br>
<br>
DT = data.table(x=c(1,1,2,2,2,3,3),y=1:7)<br>
DT2 = DT[,list(list(unique(y))),by=x]<br>
DT2<br>
x V1<br>
[1,] 1 1, 2<br>
[2,] 2 3, 4, 5<br>
[3,] 3 6, 7<br>
<br>
and list columns can be grouped; e.g.,<br>
<br>
DT2[,sum(unlist(V1)),by=list(x%%2)]<br>
x V1<br>
[1,] 1 16<br>
[2,] 0 12<br>
<br>
<br>
<br>
</blockquote></div><br></div>