I have two data frames in R as follows:
table 1
| Country name | HDI | GDP | 
|---|---|---|
| X | N/A | x_GDP | 
| Y | N/A | y_GDP | 
table 2
| Name | HDI-2018 | HDI-2019 | 
|---|---|---|
| X | (irrelevant value) | x_HDI | 
| Y | (irrelevant value) | y_HDI | 
| Z | (irrelevant value) | z_HDI | 
I want to replace the HDI column in table 1 with the 2019 HDI values in table 2 (by matching the country names). I want to exclude country Z since it is not in table 1. How would I do this in R? Is it possible using library(dplyr)?
THANK YOU!
My wanted output is below:
| Country name | HDI | GDP | 
|---|---|---|
| X | x_HDI | x_GDP | 
| Y | y_HDI | y_GDP | 
I tried using the merge command, but it merged all columns.
 
    