David Selby walks us through non-trivial join scenarios in R:
Most joins are equi-joins, matching rows according to two columns having exactly equal values. These are easy to perfom in R using the base
merge()
function, the variousjoin()
functions in dplyr and theX[i]
syntax of data.table.But sometimes we need non-equi joins or θ-joins, where the matching condition is an interval or a set of inequalities. Other situations call for a rolling join, used to link records according to their proximity in a time sequence.
How do you perform non-equi joins and rolling joins in R?
Click through for the answer using dplyr, sqldf, and data.table. H/T R-bloggers