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,
If I understand the problem, you can use table
to compute the difference in the number of elements in each set and then create a vector based on the difference of those counts (note that this won't necessarily give you the order you gave in your question).
> diffs <- table(x) - table(factor(y, levels=levels(factor(x))))
> rep(as.numeric(names(diffs)), ifelse(diffs < 0, 0, diffs))
[1] 1 1 2 3