Reputation:
I want to delete all the duplicated rows from my data.frame only if their values on another column is different.
Let's say I have a data.frame like this :
Column1 Column2 Column3
A - 10
A - 13
A - 15
B - 18
B - 18
B - 23
The result should be :
Column1 Column2 Column3
A - 10
B - 18
B - 18
Upvotes: 0
Views: 48
Reputation: 32548
df1[ave(df1$Column3, df1$Column1, FUN = function(x) x == x[1]) == 1,]
# Column1 Column2 Column3
#1 A - 10
#3 B - 18
#4 B - 18
Upvotes: 2