I see that comparing two values of type double should be done using e.g. all.equal
or by pre-specifying a tolerance level, as discussed here.
But how would you solve this for two vectors of type double: u %in% v
?
My solution so far is to use a double for-loop:
m <- vector("integer")
for (i in seq_along(u)) {
for (j in seq_along(v)) {
if (isTRUE(all.equal(u[[i]], v[[j]])))
m <- c(m, i)
}
}
Is there a better way (in terms of readability), or a more preferred way?