0

I would like to merge two data frames, A and B based on two variables - Quarter and Geography, since observations in the data frames only take a unique value based on these two variables. When using the merge function, how would you write out merging based on when two variables take the same value (i.e., both Quarter = 1 and Geography = Urban)?

merged_dataframe <-merge(df_A, fr_B, by .x = "Quarter", by.y = "Quarter")



Data frame A: 
Year    Quarter     Geography
2020    1           All
2020    1           Urban
2020    1           Rural
2020    2           All
2020    2           Urban
2020    2           Rural

Data frame B:
Year    Quarter     Geography
2021    1           All
2021    1           Urban
2021    1           Rural
2021    2           All
2021    2           Urban
2021    2           Rural
sili
  • 9
  • 2

0 Answers0