Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201943

Remove rows found in more than 3 groups

$
0
0

I have a dataframe, i am trying to remove the rows that are present in >= 3 groups. In my below example bike is the common value across 3 group and i need to remove that. Please help me to achieve this.


df <- data.frame(a = c("name1","name1","name1","name2","name2","name2","name3"), b=c("car","bike","bus","train","bike","tour","bike"))
df
    a    b
 name1  car
 name1  bike
 name1  bus
 name2  train
 name2  bike
 name2  tour
 name3  bike

Expected Output:


 a      b
 name1  car
 name1  bus
 name2  train
 name2  tour

Viewing all articles
Browse latest Browse all 201943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>