您也可以使用新实现的方法来完成 non-equi
连接来这应该更直接...
y[x, on = .(Start <= Distance, End >= Distance), mult = "last", .(AthleteID, Distance, Score, CheckpointID)]
哪里,
x=fread("AthleteID Distance Athlete1 5 Athlete2 10 Athlete3 25 ") y=fread("CheckpointID Start End Score Checkpoint1 1 8 2 Checkpoint2 7 12 4 Checkpoint3 9 15 6 Checkpoint4 16 26 8 Checkpoint5 20 30 10 ")