symdiff()
The functions union
intersect
and setdiff
implement set operations. A common operation missing from these is to take the symmetric difference of two sets (both left and right outer parts on a venn diagram but not the middle). This helper function is low cost, high utility.
symdiff <- \(x, y) setdiff(union(x, y), intersect(x, y))