this question is kind of related to this one, however i want to create an Index using a unique combination of two data.frame columns. So my data structure looks for example like this (dput):
structure(list(avg = c(0.246985988921473, 0.481522354272779,
0.575400762275067, 0.14651009243539, 0.489308880181752, 0.523678968337178
), i_ID = c("H", "H", "C", "C", "H", "S"), j_ID = c("P", "P",
"P", "P", "P", "P")), .Names = c("avg", "i_ID", "j_ID"), row.names = 7:12, class = "data.frame")
The created Index for the above structure should therefore look like this
1
1
2
2
1
3
In the example data the column j_ID always has the value P, but this isn't always the case. Furthermore vice-versa (S-P or P-S) combinations should result in the same index.
Someone knows a nice way to accomplish that? I can do it with a lot of for-loops and if-else commands, but thats not really elegant.