<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">To add to Frank’s reply, I think `dt[, V3 := .(list(V1)), by=V2]` doesn’t work with `1.9.4`, but has been fixed in 1.9.5.</div>The first list is for the syntax - (cols) := list(values). Cases like `DT[, A := 1:5]` and is internally wrapped by `list()` for convenience, as they are very common use cases.<div> <div id="bloop_sign_1435261904794275072" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Arun</div></div> <br><p class="airmail_on" style="color:#000;">On 25 Jun 2015 at 21:51:09, Frank Erickson (<a href="mailto:fperickson@wisc.edu">fperickson@wisc.edu</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>
<title></title>
<div dir="ltr">Oh, sorry, didn't notice you were making a new
column, in that case: dt[,V3:=list(list(V1)),by=V2]
<div><br></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Jun 25, 2015 at 3:48 PM, Frank
Erickson <span dir="ltr"><<a href="mailto:fperickson@wisc.edu" target="_blank">fperickson@wisc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi,
<div><br></div>
<div>I think you want</div>
<div><br></div>
<div><font face="monospace, monospace">dt[,.(list(V1)),by=V2]<br></font></div>
<div>
<div><font face="monospace, monospace"># V2
V1</font></div>
<div><font face="monospace, monospace"># 1: a
1,4</font></div>
<div><font face="monospace, monospace"># 2: b
2,3</font></div>
</div>
<div><br></div>
<div><br></div>
<div>Using the .() notation makes it easier to keep track of what
columns are being made, I find.</div>
<div><br></div>
<div>--Frank</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">
<div>
<div class="h5">On Thu, Jun 25, 2015 at 3:46 PM, Nicolas Paris
<span dir="ltr"><<a href="mailto:niparisco@gmail.com" target="_blank">niparisco@gmail.com</a>></span> wrote:<br></div>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div class="h5">
<div dir="ltr">
<div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,51,51)">Hi,</div>
<div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,51,51)"><br></div>
<div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,51,51)">Here an example
what I want to get :</div>
<div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(0,51,51)"><br></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">> dt <-
data.table(c(1,2,3,4),c("a","b","b","a"))</font><br></div>
<div class="gmail_default">
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">> dt</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"> V1 V2</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">1: 1 a</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">2: 2 b</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">3: 3 b</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">4: 4 a</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"><br></font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">What I want to get is a V3 column, containing
an aggregated vector :</font></div>
<div class="gmail_default">
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">> dt</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"> V1 V2 V3</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">1: 1 a c(1,4)</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">2: 2 b c(2,3)</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"><br></font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">That does not work :</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"><br></font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">dt[,V3 := as.list(c(V1)),by=V2]</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"><br></font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">Is there a way to do so ?</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"><br></font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif">Thanks</font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"><br></font></div>
<div class="gmail_default"><font color="#003333" face="tahoma, sans-serif"><br></font></div>
</div>
</div>
</div>
<br></div>
</div>
_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org" target="_blank">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" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
</blockquote>
</div>
<br></div>
</blockquote>
</div>
<br></div>
_______________________________________________
<br>datatable-help mailing list
<br>datatable-help@lists.r-forge.r-project.org
<br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</div></div></span></blockquote></div></body></html>