title: Finding one-to-one, one-to-many, and many-to-one relationships between columns
body: <p>Consider the following data frame:</p>
  
  <pre><code> first_name last_name
  1         Al     Smith
  2         Al     Jones
  3       Jeff  Thompson
  4      Scott  Thompson
  5      Terry    Dactil
  6       Pete       Zah
  
  data &lt;- data.frame(first_name=c("Al","Al","Jeff","Scott","Terry","Pete"),
                     last_name=c("Smith","Jones","Thompson","Thompson","Dactil","Zah"))
  </code></pre>
  
  <p>In this data frame, there are three ways that first_name is related to last_name:</p>
  
  <ul>
  <li>One to one (i.e. there is a unique relationship between first_name
  and last_name) </li>
  <li>One to many (i.e. one first_name points to multiple
  last_name values) </li>
  <li>Many to one (i.e. multiple first_name values point
     to one last_name)</li>
  </ul>
  
  <p>I want to be able to quickly identify each of the three cases and output them to a data frame. So, the resulting data frames would be:</p>
  
  <p>One to one</p>
  
  <pre><code>  first_name last_name
  1      Terry    Dactil
  2       Pete       Zah
  </code></pre>
  
  <p>One to many</p>
  
  <pre><code>  first_name last_name
  1         Al     Smith
  2         Al     Jones
  </code></pre>
  
  <p>Many to one</p>
  
  <pre><code>   first_name last_name
  1       Jeff  Thompson
  2      Scott  Thompson
  </code></pre>
  
  <p>I would like to do this within the dplyr package.</p>