0

I am working on two datasets and i want to merge them, because i would like to investigate the relationship between some variables and run some linear regressions. Note that my datasets are quite big and may i face problem of adding them here.

A process i had followed with some datasets (But this process doesnt work on my situation here!):

I have a dataset called CountryLevel and a dataset called Diversity.

With the above process i manage to merge them by ISO3 :

CountryLevel<-read_dta("C:/Users/ILIAS/Documents/CountryLevel.dta")
Diversity <-read_dta("C:/Users/ILIAS/Documents/diversity.dta")

ISO3<-c(0,224)

for (i in 1:224) 
{
  ISO3[i]=CountryLevel$code[i]
  
}


CountryLevel <- data.frame(CountryLevel, ISO3) 

data1 <- merge(CountryLevel, Diversity, by='ISO3', all=TRUE)

CountryLevel Dataset

Diversity Dataset

Now in the datasets GemData and GlobeData, i cant used the same procedure because the Globe Data has that ability !! You can see:

GemData and GlobeData

Any advice here to merge them in order to get all the variables from the two datasets for each country?

Vinícius Félix
  • 4,501
  • 3
  • 12
  • 28
Nikolas
  • 1
  • 1
  • Joining two tables is a common task, and there are built-in approaches to do this more easily and efficiently. Look at the help for the `merge` function by typing `?merge`, and/or look up "join two tables [r]`. Here's a comprehensive answer: https://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right – Jon Spring Oct 07 '21 at 15:57

0 Answers0