I have two datasets, and I want to know at which location their elements are different, so I use the code below:
In this example, a1 and a2 are the datasets to be compared. The "a2" has two differnt elements: one is [3,1], the other is [8,2] which is "NA".
a1 <- data.frame(num = 1:8, lib = letters[1:8])
a2 <- a1
a2[[3,1]] <- 2
a2[[8,2]] <- 2
a1; a2
which(a1 != a2, arr.ind = TRUE)
However, the which() function only finds one difference "[3,1]". It seems that it cannot find the "NA" difference. How can I find both [3,1] and [8,2] differences?