title: Compare two groups to see if they have the same people and assign ID to similar groups
body: <p>I'd like to create a master "Household ID" for groups that have the same people in each household. For example, say I have a dataset with 4 people that are found in seven different households. </p>
  
  <pre><code>dt &lt;- read.table(header=T, text='
          p_id    hh_id
          1   100
          2   100
          3   100
  
          1   200
          2   200
          3   200
  
          1   300
          2   300
          3   300
          4   300
  
          2   400
          3   400
  
          2   500
          3   500
          4   500
  
          2   600
          3   600
  
          2   700
          3   700
          4   700
               ')
  </code></pre>
  
  <p>I'd like to create a master household ID that identified households that had the same ID based on exactly who was in the household. </p>
  
  <pre><code>        p_id    hh_id   master_id
          1       100     1       
          2       100     1
          3       100     1
          1       200     1
          2       200     1
          3       200     1
          1       300     2
          2       300     2
          3       300     2
          4       300     2
          2       400     3
          3       400     3
          2       500     4
          3       500     4
          4       500     4
          2       600     3
          3       600     3
          2       700     4
          3       700     4
          4       700     4
  </code></pre>
  
  <p>BONUS: What would be the best way to add a weight to this ID calculation based on some criteria, like whether most of the "primary" people were in the other households? For example, if person 1 and 2 are adults, and 3 and 4 are children, how could we make keep a master <code>master_id</code> when 1 and 2 are together, but different when one of them is missing? </p>
  
  <pre><code>        p_id    hh_id   master_id   wt_m_id
          1       100     1           1       
          2       100     1           1
          3       100     1           1
          1       200     1           1
          2       200     1           1
          3       200     1           1
          1       300     2           1
          2       300     2           1
          3       300     2           1
          4       300     2           1
          2       400     3           2
          3       400     3           2
          2       500     4           2
          3       500     4           2
          4       500     4           2
          2       600     3           2
          3       600     3           2
          2       700     4           2
          3       700     4           2
          4       700     4           2    
  </code></pre>
  
  <p>I tried the following code but it only create sequential numbers or was trying to get at something completely different. </p>
  
  <pre><code>dt %&gt;% mutate(new_id = interaction(p_id, hh_id)) 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>dt %&gt;% mutate(ID = group_indices_(dt, .dots=c("p_id", "hh_id")))
  </code></pre>