Comparing character vectors in R to find unique and/or missing values Comparing character vectors in R to find unique and/or missing values r r

Comparing character vectors in R to find unique and/or missing values


> x[!x %in% y][1] "b" "f"

or:

> x[-match(y,x)][1] "b" "f"> 


I think this should work:

x[!(x %in% y)]

First it checks for all x that are not in y, then it uses that as an index on the original.