Model<-c("A","A","A","A","A","B","B","B","B","B","C","C","C","C")
Price<-c(12,14,15,13,16,36,32,24,14,15,14,11,24,31)
region<-c("W","E","E","W","W","E","E","E","E","W","W","W","E","W")
dt<-data.frame(Model,Price,region)
Model Price region
1 A 12 W
2 A 14 E
3 A 15 E
4 A 13 W
5 A 16 W
6 B 36 E
7 B 32 E
8 B 24 E
9 B 14 E
10 B 15 W
11 C 14 W
12 C 11 W
13 C 24 E
14 C 31 W
>
What I want to do is delete the rows if only one W or E happened in that Model type. We keep all rows for model A. We delete the 10th row because only 1 W in model B. And we also delete 13th row because only 1 E in model C.
How can do this in R? I have about 20,000 observations with thousands of model type. I may need to write a loop.