EDITED:
I have a very simple question. I have a dataframe (already given) with repeated rows. I want to identify each unique row and add a column with an ID number.
The original table has thousands of row, but I simplify it here. A toy df can be created in this way.
df <- data.frame(var1 = c('a', 'a', 'a', 'b', 'c', 'c', 'a'),
var2 = c('d', 'd', 'd', 'e', 'f', 'f', 'c'))
For each unique row, I want a numeric ID:
var1 var2 ID
1 a d 1
2 a d 1
3 a d 1
4 b e 2
5 c f 3
6 c f 3
7 a c 4
/EDITED