If I have a df like this
data<-data.frame(id=c(1,1,3,4),n=c("x","y","e","w"))
data
id n
1 1 x
2 1 y
3 3 e
4 4 w
I want to get a new df like this:
data
id n
3 3 e
4 4 w
That is, I want it to remove all repeating rows. I've tried functions like distinct from dplyr but it always gets one of the repeating rows.
Another subset option with ave
subset(
data,
ave(n, id, FUN = length) == 1
)
gives
id n
3 3 e
4 4 w
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With