If I have two data.tables, dt1
, and dt2
, I want the number of matches between columns using an if then sort of logic. If dt1$V1==dt$V2
, then does dt$V1 == dt$V2
? But it is key for this if-then statement to group by the matches in dt1$V1 == dt$V2
. I would like to use data.table for its efficiency, since I actually have a large dataset.
dt1 <- data.table(c("a","b","c","d","e"), c(1:5))
dt2 <- data.table(c("a","d","e","f","g"), c(3:7))
In this dummy example, there are 3 matches between the V1s, but only two within those groups for V2s. So the answer (using nrow
perhaps, if I subset), would be 2.