I have used the call below to \"join\" my datasets based on an inequality condition:
library(sqldf)
sqldf(\"select *
from dataset1 a,
dataset2 b
a.col1 <
Non-equi (or conditional) joins were recently implemented in data.table, and available in the current development version, v1.9.7. See installation instructions here.
require(data.table) # v1.9.7+
setDT(dataset1) # convert to data.tables
setDT(dataset2)
dataset1[dataset2, on=.(col1 < col2), nomatch=0L]
For each row of dataset2
, find matching row indices while joining on condition provided to the on
argument, and return all columns for those matching rows.