Hello,

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.

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:

tmp <- sqldf("select a.Field1, a.Field2, a.Field3, b.Output from MyDataset
a INNER JOIN MyDataset b on a.Field1 =b.Field1 and *a.Field2 = b.Field2+1*
and a.Field3=b.Field3")
tmp <- as.data.table(tmp)
setkey(MyDataset, Field1, Field2, Field3)
setkey(tmp, Field1, Field2, Field3)
MyDataset[tmp,Field4 := i.Output, nomatch=0]

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).

Is there an elegant way to address this?

Many thanks

Stefano
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to