That\'s x \\ y
using mathematical notation. Suppose
x <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2,1,1,1,3)
y <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,
Here a solution using pmatch
(this gives the "complement" as you require):
x <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2,1,1,1,3)
y <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1)
res <- x[is.na(pmatch(x,y))]
From pmatch
documentation:
"If duplicates.ok is FALSE, values of table once matched are excluded from the search for subsequent matches."