setdiff() is a tricky function because the output is dependent on the order of the input. You can instead write a simple function as such that does the exact opposite of intersect. This is far better.
will give you the right answer [1] 1, if the goal is to find the values/characters in x, that is not present in y.
However, applying the above expressions can be tricky and can give undesirable results depending on the nature of the vector, and the position of x and y in the expression. For instance, if:
x <- c(1,1,2,2,3,4)
y <- c(2,3,4)
and the goal is just to find the unique values/characters in x, that is not present in y or vice-versa. Applying any of these expressions will still give the right answer [1] 1: