I have a vector like this:
x = c(1,2,3,4,5,6,4,5,6,7)
> x
[1] 1 2 3 4 5 6 4 5 6 7
I want to get rid of duplicates and get something like this:
> [1] 1 2 3 7
My attempt
y = x[duplicated(x)]
> y
[1] 4 5 6
> x[x!=y]
[1] 1 2 3 7
Warning message:
In x != y : longer object length is not a multiple of shorter object length
>
What am I doing wrong?
Is this error something I should worry about?
Is there another way to do this without getting an error?