Merge together two files

Hello everyone,
I am struggling merging two files together. I explain : in need to merge two files (one file is dataset 4 and contain list the gdp per year for certain countries. The other one is dataset 3 and contain the population for certain countries, including for countries that are listed in the first one but not solely).
I have used this : dataset4 = merge(x = dataset4, y = dataset3,) to do it but that leads to this

What i precisily need to do is not clear but i think i must do something more like having the countries listed and when there is both pop and gdp variables available for it, it shows everything in the same row and when it's not the case, you only have one of both variable.

I joint two pictures of my dataset (dataset3 and dataset 4) in order to make it more clear. (in comments!!!!!)
Is it possible that the fact that in the dataset 4, Country is in capital letters (COUNTRY) and in the dataset 3, country is written Country, the source of the problem ?
I also think that i have to create an independent "newdataset" (the one that has been created after merging the other)

Thanks in advance and best regards,

1 Like

Hi, can you provide a reproducible example instead of a screenshot? It makes it much easier to help. Can you also share the code that you have tried?

Like said @williaml, is better help you if put the example data
Paste the result of:

joined_df <- merge(dataset3, dataset4,
                   by.x = "Country",  # check the name of column in each dataset.
                   by.y = "COUNTRY")


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.