title: Creating ID numbers based on two string columns
body: <p>I have a data frame structured as follows: </p>
  
  <pre><code>df &lt;- structure(list(NAME1    =  c("AAA","CCC","BBB","BBB"), 
                   NAME2        =  c("BBB", "AAA","DDD","AAA"),
                   AMT          =  c(10, 20, 30, 50)), .Names=c("NAME1","NAME2", "AMT"), 
              row.names         = c("1", "2", "3", "4"), class =("data.frame"))
  </code></pre>
  
  <p>I would like to create two ID variables (ID1 and ID2) based on two string columns, namely NAME1 and NAME2. The two columns may share values so the IDs have to be consistent. The desired data frame should look like this:</p>
  
  <pre><code>df &lt;- structure(list(NAME1    =  c("AAA","CCC", "BBB", "BBB"), 
                   NAME2        =  c("BBB", "AAA","DDD", "AAA"),
                   ID1          =  c(1,3,2,2),
                   ID2          =  c(2,1,4,1),
                   AMT          =  c(10,20,30,50)),
              .Names            =  c("NAME1","NAME2","ID1","ID2"), 
              row.names         =  c("1", "2", "3", "4"), class =("data.frame"))
  </code></pre>
  
  <p>Your suggestions would be appreciated.</p>
  
  <p>Cheers. </p>