The syntactic sugar (together with super-speed) for this is achieved by data.table
:
library(data.table)
a = as.data.table(a)
setkey(a, V1)
a[J(b)]
# V1 V2
#1: 1 6
#2: 4 9
#3: 1 6
If b
is also a data.table
, it's even nicer:
b = as.data.table(b)
a[b]
# V1 V2
#1: 1 6
#2: 4 9
#3: 1 6