Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check for unique elements

Tags:

r

just a simple question. I have a data frame(only one vector is shown) that looks like:

cln1
A
b
A
A
c
d
A
....

I would like the following output:

cln1
b
c
d

In other words I would like to remove all items that are replicated. The functions "unique" as well as "duplicated" return the output including the replicated element represented one time. I would like to remove it definitively.

like image 740
Fuv8 Avatar asked Dec 05 '22 12:12

Fuv8


1 Answers

You can use setdiff for that :

R> v <- c(1,1,2,2,3,4,5)
R> setdiff(v, v[duplicated(v)])
[1] 3 4 5
like image 181
juba Avatar answered Dec 19 '22 06:12

juba