It might be easier to implement in R if you employ the base functions that take arrays and operate on them as if they represented sets. See the help() for "union", "intersect", "setdiff", "setequal" and the operator "%in%". -- Best regards, Ivan