I have 3 data frames from which I have to find a continent with less than two countries and delete these countries (rows). Data frames are structured in the same way as a data frame, called x below:
row Country Continent Ranking
1 Kenya Africa 17
2 Gabon Africa 23
3 Spain Europe 04
4 Belgium Europe 03
5 China Asia 10
6 Nigeria Africa 14
7 Holland Europe 01
8 Italy Europe 05
9 Japan Asia 06
At first I wanted to know the frequency of each country on the continent, so I did x2<-table(x$Continent)
x2
Africa Europe Asia
3 4 2
Then I wanted to identify continents with less than two countries.
x3 <- x2[x2 < 10]
x3
Asia
2
Now my problem is how to remove these countries. In the example above, these will be two countries in Asia, and I want my latest dataset to look like this:
row Country Continent Ranking
1 Kenya Africa 17
2 Gabon Africa 23
3 Spain Europe 04
4 Belgium Europe 03
5 Nigeria Africa 14
6 Holland Europe 01
7 Italy Europe 05
The number of continents with less than two countries will vary between different data frames, so I need one universal method that I can apply to everyone.
user4888445