Reputation: 121
I have something like testDF <- data.frame(v1 = c( 1, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 7, 7 ,9),v2 = c("a","b","c","d","d","e","e","e","d","d","a","a","a","b") )
and I need for each obs on v1, to get rid of the duplicates in v2... to get something like
testDF <- data.frame(v1 = c( 1, 2, 3, 4, 4, 5, 5, 5, 7, 9),
v2 = c("a","b","c","d","e","e","d","a","a","b") )
any idea on how can I do that??? thanks!
Upvotes: 1
Views: 113
Reputation: 1092
Just use unique(testDF)
you than get the following output
v1 v2
1 1 a
2 2 b
3 3 c
4 4 d
6 4 e
8 5 e
9 5 d
11 5 a
12 7 a
14 9 b
Upvotes: 4