Could use identical()with package digest:
library(digest)
x <- data.frame(aa = c("s", "d", "f"), bb = 1:3)
ans1 <- data.frame(bb = c("d", "s", "z"), cc = 1:3)
(myMatches<-lapply(x, function(myX) sapply(ans1,
function(y) identical(digest(y), digest(myX))))
)
This means that the data in the column bbin data.frame is xequal to the data in the column ccin data.frame ans1.
To get only matches,
unlist(lapply(myMatches, function(x) which(x)))
, bb x cc ans1