I have a dataset with Zip codes and corresponding cities. In some cases the zip code is missing, so I want to replace it with a zip code from the zipcode library in R.
Obviously 'New York' has more than one zip code. In my dataset with transactions the same residents appear multiple times, hence also their city e.g. 'New York' appears multiple times.
Using dplyr's left_join function, joining on the city name, I get the corresponding zip codes for the city name 'New York', like so:
10001,
10002,
10003,
etc.
Comparing this to vlookup, Excel would always take the first possible lookup match, in this case 10001.
Based on what logic is here R matching 'New York' with different zip codes in each row?