> a <- c("a","b","c")
> b <- c("b","c","d","b","d")
> setdiff(testa, testb)
[1] "a"
> setdiff(testb, testa)
[1] "d"
> union(testa, testb)
[1] "a" "b" "c" "d"
> intersect(testb, testa)
[1] "b" "c"
适用于 data frame
mtcars$model <- rownames(mtcars)
first <- mtcars[1:20, ]
second <- mtcars[10:32, ]
intersect(first, second)
union(first, second)
setdiff(first, second)
setdiff(second, first)