0

I guess this is a simple question but I would like to do the following sqldf code using data.table to do it much faster :

    data2=sqldf("select a.*, b.*
                        from data as a inner join data_others as b
                      on a.cle = b.cle and a.date_1 >= b.date_2")

I've tried the following code without success :

 data2=data[data_others ,on=.(CLE=CLE,DATE_1 >= DATE_2),nomatch=NULL]

This code produces almost the results I want, but i also want to keep column "DATE_2" and globally all the columns present in data_others but not in data, and avoid columns with names starting with "i.".

I guess there is an easy way to do it but I'm not enough familiar with data.table package.

Thanks in advance!

Phil
  • 7,287
  • 3
  • 36
  • 66
WalliYo_
  • 173
  • 7
  • you need to specifically select/name the columns you want to show : `data2=data[data_others ,.(CLE,DATE1=x.DATE1,DATE2=i.DATE2),on=.(CLE=CLE,DATE_1 >= DATE_2),nomatch=NULL]` – Waldi Feb 09 '23 at 16:57

0 Answers0