Im about to modify a dataframe because it includes double values
Data Frame:
Id Name Account
1 X 1
1 Y 2
1 Z 3
2 J 1
2 T 4
3 O 2
So when there are multiple rows with same Id
I just want to keep the last row.
The desired output would be
Id Name Account
1 Z 3
2 T 4
3 O 2
This is my current Code:
for (i in 1:(nrow(mylist)-1)) {
if(mylist$Id[c(i)] == mylist$Id[c(i+1)]){
mylist <- mylist[-c(i), ]
}
}
I have Problems when a row is removed because all other rows get a lower index and the System skips rows in the next step.