title: Remove duplicate observations based on set of rules
body: <p>I am trying to remove duplicate observations from a data set based on my variable, id. However, I want the removal of observations to be based on the following rules. The variables below are id, the sex of household head (1-male, 2-female) and the age of the household head. The rules are as follows. If a household has both male and female household heads, remove the female household head observation. If a household as either two male or two female heads, remove the observation with the younger household head. An example data set is below.</p>
  
  <pre><code>id = c(1,2,2,3,4,5,5,6,7,8,8,9,10)
  sex = c(1,1,2,1,2,2,2,1,1,1,1,2,1)
  age = c(32,34,54,23,32,56,67,45,51,43,35,80,45)
  data = data.frame(cbind(id,sex,age))
  </code></pre>