To find rows in the first object that are not present in the second object, you can use the compare function from the compare package that compares two objects and, if they are not the same, attempt to transform them to see if they are the same after being transformed.
The compare function is flexible in terms of what kind of comparisons are allowed (e.g. changing order of elements of each vector, changing the order and names of variables, shortening variables, changing the case of strings).
The “correct” object.
The object to be compared with the model.
Allow any sort of transformation
In your case:
a1 <- data.frame(a = 1:5, b = letters[1:5])
a2 <- data.frame(a = 1:3, b = letters[1:3])
To find similar rows:
comp <- compare(a1,a2,allowAll=TRUE)
1 1 a
2 2 b
3 3 c
To find missing rows:
missing <-data.frame(lapply(1:ncol(a1),function(x) setdiff(a1[,x],comp$tM[,x])))
colnames(missing) <- colnames(a1)
1 4 d
2 5 e