If we are comparing the 'v1' column in 'a1' and 'a2' datasets, and use & instead of &&, we get the expected output
a1[(a1$v1==a2$v1) & (a1$v3==a2$v3) & (a1$v2 != a2$v2), , drop=FALSE]
# v1 v2 v3
#1 ABCA1 --> GIF
According to the description from ?"&&"
‘&’ and ‘&&’ indicate logical AND and ‘|’ and ‘||’ indicate
logical OR. The shorter form performs elementwise comparisons in
much the same way as arithmetic operators. The longer form
evaluates left to right examining only the first element of each
vector.
Update
If we need to compare one row in 'a1' against all the rows, we can paste the rows in each datasets using do.call(paste,.., and loop through lapply on the paste elements of 'a1' and compare against the pasted 'a2' or this can be done using outer.
lapply(do.call(paste, a1), '==', do.call(paste, a2))
Or
outer(do.call(paste, a1), do.call(paste, a2), '==')
data
a1 <- structure(list(v1 = c("ABCA1", "ACTA1", "ACTN4", "ACTN4"),
v2 = c("-->",
"--|", "--|", "-->"), v3 = c("GIF", "CSNK2A1", "HDAC7", "RARA"
)), .Names = c("v1", "v2", "v3"), class = "data.frame",
row.names = c(NA, -4L))
a2 <- structure(list(v1 = c("ABCA1", "ACTA1", "ABCD2", "ACTN4"),
v2 = c("--|",
"--|", "--|", "-->"), v3 = c("GIF", "CSNK2A1", "HDAC7", "XYZ1"
)), .Names = c("v1", "v2", "v3"), class = "data.frame",
row.names = c(NA, -4L))