I would like to create an incrementing variable (Id1 or Id2) from 2 others variables (Var1 and Var2).
Thank you. Elodie
EDIT (reproductible example for Aaron Montgomery) I want to create an incrementing variable : "Id". The value of "Id" changes if VarA is a new value and if VarB is a new value. See in particular when Id = 4 in the expected table.
data_example <- data.table::fread("
VarA VarB
A1 B1
A1 B2
A1 B3
A1 B4
A2 B5
A3 B6
A4 B7
A5 B7
A5 B8
A6 B9
A7 B10
A8 B10
A9 B10")
Expected table
VarA VarB Id
A1 B1 1
A1 B2 1
A1 B3 1
A1 B4 1
A2 B5 2
A3 B6 3
A4 B7 4
A5 B7 4
A5 B8 4
A6 B9 5
A7 B10 6
A8 B10 6
A9 B10 6
dput()) would also be helpful.