I have a data.frame which has duplicate observations, how do I delete all the duplicated ones based on the first column (if their first data is the same, then delete these entries entirely)?
> a=c(1,4,5,5,6,6)
> b=c(2,5,7,4,4,2)
> c=c("a","b","c","a","b","c")
> test=data.frame(a,b,c)
> test
a b c
1 1 2 a
2 4 5 b
3 5 7 c
4 5 4 a
5 6 4 b
6 6 2 c
I don't want to keep any of the duplicate rows so that my final output will be
a b c
1 1 2 a
2 4 5 b
I've tried unique
and duplicate
function but they both keep the first duplicate rows (i.e., if there are 5 duplicate records then 4 of them will be deleted), like
a b c
1 1 2 a
2 4 5 b
3 5 7 c
4 6 4 b
What should I do? Thanks!