Hi all, I am trying to create a new variable depending on already existing values in the table but got stuck.. here is the example
colA colB new_col1 new_col2 jet a 1 1 jet b 1 1 cat c 1 2 cat d 1 2 dog e 2 3 hen f 3 4
I need to create new columns (new_col1 & new_col2) . I am looking to assign a common value for new_col1 if the values in colA are duplicates and values in colB are unique (i.e jet and cat should get the value of 1 in new_col1) and assign a separate value for each duplicate value in colA (i.e . jet should get 1 and cat should get 2 in new_col2).
Could anyone please help me in getting this result? Really appreciate any help on this issue!