so this is my main data
Country Consumption Rank
Belarus 17.5 1
Moldova 16.8 2
Lithuania 15.4 3
Russia 15.1 4
Romania 14.4 5
Ukraine 13.9 6
I have also collected these another data frames of continents like:
europe
Albania
Andorra
Armenia
Austria
Azerbaijan
Belarus
or another data frame like
asia
Afghanistan
Bahrain
Bangladesh
Bhutan
Brunei
6 Burma (Myanmar)
I want to match the countries of my data with the continents countries data frames I have and then label them with the continents like Europe or Asia
here is the code I have managed but does not match them so the else if executes only:
if ( data$Country %in% europe$europe) {
data$con<-c("Europe")
} else if ( data$Country %in% asia$asia) {
data$con<-c("asia")
} else if ( data$Country %in% africa$africa) {
data$con<-c("africa")
} else
data$con<-c("ridi")
thank you in advance.