I want to recode the values in my second data frame based on the corresponding value in a different data frame.
for example, here's what the first data frame looks like. Each code is assigned to a corresponding zone.
| zone | code |
|---|---|
| 1 | 12345 |
| 2 | 23456 |
| 2 | 23457 |
| 2 | 23458 |
| 3 | 45678 |
| 3 | 45679 |
the second data frame looks like this:
| to_code | fr_code |
|---|---|
| 23456 | 12345 |
| 23457 | 23456 |
| 45678 | 23457 |
| 45678 | 23458 |
| 12345 | 45678 |
| 12345 | 23457 |
but I want to recode it based on the corresponding zones, so it would look like this:
| to_code | from_code |
|---|---|
| 2 | 1 |
| 2 | 2 |
| 3 | 2 |
| 3 | 2 |
| 1 | 3 |
| 1 | 2 |