<div dir="ltr">try this:<div><br></div><div><div>> dt = data.table (x=10:14, y=20:24)</div><div>> # create new 'x' column</div><div>> dt[, newX := x]</div><div>> dt[</div><div>+     , list(x = toString(x)</div>
<div>+         , y = toString(y)</div><div>+         )</div><div>+     , key = newX %% 3</div><div>+     ]</div><div>   newX      x      y</div><div>1:    0     12     22</div><div>2:    1 10, 13 20, 23</div><div>3:    2 11, 14 21, 24</div>
</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><br>Jim Holtman<br>Data Munger Guru<br> <br>What is the problem that you are trying to solve?<br>Tell me what you want to do, not how you want to do it.</div>

<br><br><div class="gmail_quote">On Sun, Apr 27, 2014 at 7:47 AM, Dan Muresan <span dir="ltr"><<a href="mailto:danmbox@gmail.com" target="_blank">danmbox@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How do I achieve the following partitioning effect:<br>
<br>
dt = data.table (x=10:14, y=20:24)<br>
aggregate (dt, by = list (dt$x %% 3), FUN = list)<br>
<br>
  Group.1      x      y<br>
1       0     12     22<br>
2       1 10, 13 20, 23<br>
3       2 11, 14 21, 24<br>
<br>
If I try the following it doesn't work (and I think I know why):<br>
<br>
dt [, by = x %% 3, j = list(y)]<br>
   x  y<br>
1: 1 20<br>
2: 1 23<br>
3: 2 21<br>
4: 2 24<br>
5: 0 22<br>
<br>
(while with j = max (y) it of course works, generating a "V1" column)<br>
<br>
Also, how do I name the result of the j-expression (by default the<br>
resulting column is "V1")?<br>
_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
</blockquote></div><br></div>