I have a table which looks the following way:
Name | Region | Id |
---|---|---|
Name1 | US | 123 |
Name1 | US | |
Name2 | US | 122 |
Name3 | US | 124 |
Name1 | UK | |
Name1 | UK | 135 |
Name2 | UK | 140 |
Name3 | US |
As you can see there are empty values in the ID column which I want to be filled with the values of other rows if the column Name and Region correspond. So it should look like this:
Name | Region | Id |
---|---|---|
Name1 | US | 123 |
Name1 | US | 123 |
Name2 | US | 122 |
Name3 | US | 124 |
Name1 | UK | 135 |
Name1 | UK | 135 |
Name2 | UK | 140 |
Name3 | US |
Some of the columns will still be left empty but the majority will be fine. Is there a way to do so in R? Maybe it will be easier to so in Excel even (Vlookup maybe I am not sure). Share if you have any ideas)