title: Average numerical data but keep categorical data
body: <p>I am looking to combine duplicate subjects, however some of my data is numerical and some is categorical.  The categorical values are duplicated but the numerical data may differ.  I want to average the numerical data but merge the categorical data.</p>
  
  <p>For example:</p>
  
  <pre><code>Subject A   B
     1    L   1
     1    L   0
     2    R   1
     2    R   1
     3    L   0
     3    L   1
     4    R   1
     4    R   1
  </code></pre>
  
  <p>This is what I want it to look like:</p>
  
  <pre><code>Subject A   B
     1    L   0.5
     2    R   1
     3    L   0.5
     4    R   1
  </code></pre>
  
  <p>I tried using aggregate() but it wasn't working since column A is non-numerical data.</p>
  
  <p>Thoughts on how to solve this problem?
  Thank you!</p>