0
library(tidyverse)

data<-diamonds%>%group_by(cut,color,clarity)%>%
  summarize(aver=round(mean(price),0),count=n())%>%
  filter(count>10)%>%
  mutate(rank1=min_rank(desc(aver)),rank2=cume_dist(desc(aver)))

So when you run this script you will get output below. Now in cut and color column there are just 3 combinations " Fair D" which is also possible to see from rank1 column. Another group " Fair E" has 5 rows. I want to keep just rows for groups with more than 3 rows .

enter image description here

Cath
  • 23,906
  • 5
  • 52
  • 86
Tomas H
  • 713
  • 4
  • 10

1 Answers1

2

We can use filter with a logical condition (n() > 3) to keep only groups that have number of rows greater than a particular value

data %>% 
     filter(n()>3)
akrun
  • 874,273
  • 37
  • 540
  • 662