I am working with the following data. We can call it x
New_Name_List Old_Name_List
1 bumiputera bumiputera (muslims)
2 bumiputera bumiputera (other)
3 non bumiputera non bumiputera (indigenous)
4 chinese chinese
The goal is to recode data in another data object that looks like this. We can call it y
EPR_country_code EPR_country EPR_group_lower_2
1 835 Brunei bumiputera (muslims)
2 835 Brunei bumiputera (other)
3 835 Brunei non bumiputera (indigenous)
4 835 Brunei chinese
If x$New_Name_List
has duplicate values I want the x$Old_Name_List
values in the new column y$EPR_group_lower_3
.
If x$New_Name_List
has unique values, I want the x$New_Name_List
in the new column, y$EPR_group_lower_3
.
So that the data will look like this at the end:
EPR_country_code EPR_country EPR_group_lower_2 EPR_group_lower_3
1 835 Brunei bumiputera (muslims) bumiputera (muslims)
2 835 Brunei bumiputera (other) bumiputera (other)
3 835 Brunei non bumiputera (indigenous) non bumiputera
4 835 Brunei chinese chinese
Thank you so much