I want to add 3 more columns: Country, City and Continent.
so if all_Data$Favorite = Apple then the Country=France, City= Paris and Continent= Europe.
and if all_Data$Favorite=Lemon or Orange then the Country=Greece, City=Athens and Continent=Europe
if all_Data$Favorite=Onion then the Country=Kenya, City=Nairobi and Continent=Africa
I have tried the following but it does not work.
all_Data$Country<- NA
all_Data$City<- NA
all_Data$Continent<-NA
if (all_Data$Favorite=="Apple") {
all_Data$Country<-c("France") |all_Data$City<-c("Paris"| all_Data$Continent="Europe")
} else if (all_Data$Favorite=="Lemon"| all_Data$Favorite=="Orange"){all_Data$Country="Greece" | all_Data$City="Athens"| all_Data$Continent="Europe"
} else {all_Data$Country="Kenya"| all_Data$City="Nairobi"| all_Data$Continent="Africa"}
I need a solution that can be generalized to a large number of variables
How can I do this?
Thanks in advance