I know that this question has been repeated multiple times but I am not able to look exactly for what I am looking for in the previous topics. Please feel free to close the topic in case that this is duplicated.
I have a dataframe as follows:
> data %>% arrange(customer_id)
region market unit_key
1 2 98 320
2 2 98 321
3 4 184 287
4 4 4 7
5 4 4 287
6 66 521 899
7 66 521 900
8 66 3012 899
9 66 521 916
10 66 3011 900
I would like to make a 4th column which is a unique identifier call combination id that is formed as follows:
So basically for each unique pair of region and market I should get a unique identifier that will allow me to retrieve the unit_keys that they are linked with the combination of markets for an specific region.
I tried to do it with a cross-join and with tidyr::crossing() but I didnt get the expected results.
Any hints on this topic?
BR /Edgar