<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Joins vignettes aren't done yet 😔. It is planned for v1.9.8. Will work on it after wrapping up things I am working on now.<br><br><div>Arun</div><div>--</div>Sent from my iPhone</div><div><br>On 09 Nov 2015, at 02:43, Stefano Grioni <<a href="mailto:sgrioni@chicagobooth.edu">sgrioni@chicagobooth.edu</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><span style="font-size:13px;line-height:19.5px">Hello,</span><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">As I was reading through the vignette on data handling and joins, it was not immediately evident to me how to do an update on auto-join using only data table.</div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">I have managed to do what I need using by using SQL, but I don't find it particularly elegant and performance will probably be terrible on large datasets:</div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px"><div>tmp <- sqldf("select a.Field1, a.Field2, a.Field3, b.Output from MyDataset a INNER JOIN MyDataset b on a.Field1 =b.Field1 and <b>a.Field2 = b.Field2+1</b>and a.Field3=b.Field3")</div><div>tmp <- as.data.table(tmp)</div><div>setkey(MyDataset, Field1, Field2, Field3)</div><div>setkey(tmp, Field1, Field2, Field3)</div><div>MyDataset[tmp,Field4 := i.Output, nomatch=0]</div></div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">I tried to do the same using twice the same data frame but I can't see how to integrate the join condition on Field2 (see above).</div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">Is there an elegant way to address this?</div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">Many thanks</div><div style="font-size:13px;line-height:19.5px"><br></div><div style="font-size:13px;line-height:19.5px">Stefano</div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>datatable-help mailing list</span><br><span><a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a></span><br><span><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></span></div></blockquote></body></html>