补充功能

时间:2015-03-20 16:12:06

标签: r complement

我的数据:

a <- c('KK','LL','II','JJ','AA','CC','GG','FF','EE','QQ','ZZ','XX')
b <- c('CC','GG','FF','EE','KK','LL','II','JJ','QQ','ZZ','XX','BB','AA','OO','WW')

列出所有“&#34; b&#34;具有但&#34; a&#34;没有“

我尝试:

union(a,b)

[1] "KK" "LL" "II" "JJ" "AA" "CC" "GG" "FF" "EE" "QQ" "ZZ" "XX" "BB" "OO"
[15] "WW"

intersect(a,b)

[1] "KK" "LL" "II" "JJ" "AA" "CC" "GG" "FF" "EE" "QQ" "ZZ" "XX"

1 个答案:

答案 0 :(得分:0)

如果是R语言:

setdiff(b, a)

另见the docs on set operations