I have the dt and dt1 data.tables.
dt
dt1
data.table
dt<-data.table(id=c(rep(2, 3), rep(4, 2)), year=c(2005:2007, 2005:2006), event=
setkeyv(dt,c('id','year')) setkeyv(dt1,c('id','year')) dt[dt1,nomatch=0]
Output -
> dt[dt1,nomatch=0] id year event performance 1: 2 2005 1 1000 2: 2 2006 0 1001 3: 2 2007 0 1002