I have created a formula in excel with iferror and vlookup(mentioned below).Can you please let me know how can I replicate the same in R
This lookup goes to main_df which matches with various column named E&F
So the condition is vlookup on column E with sheet1 if error then vlookup on F with sheet2 and if error then again vlookup upon E with sheet3.So basically every time I get a NA it should pick up only those values and do the next vlookup.
IFERROR(IFERROR(VLOOKUP($E2,'sheet1'!$K:$L,2,0),VLOOKUP($F2,'sheet2'!$A:$B,2,0)),VLOOKUP($E2,'sheet3'!$N:$O,2,0))
Edit:
   main_df
    Countries   City
    USA         Texas
    India       Mumbai
    China       Hunan
    Veitnam     Hue
Other DF
df_sheet1                            df_sheet2
    Countries Population          City      Population
    USA       1000000             Hunan     239857688
    India     118947759           Hue       667588
Desired output final_df
main_df
Countries   City      Population
USA         Texas     1000000
India       Mumbai    118947759
China       Hunan     239857688
Veitnam     Hue       667588
 
     
    