How to summarize_each with mixed column class
<p>Consider the situation, where I want to <code>summarize_each</code> a data.frame with mixed column type.</p>

<pre><code>&gt; (temp=data.frame(ID=c(1,1,2,2),gender=c("M","M","F","F"),val1=rnorm(4),val2=rnorm(4)))
  ID gender       val1       val2
1  1      M -1.7944804  0.5232313
2  1      M  0.3938437 -0.8424086
3  2      F -0.3190777  0.3220580
4  2      F  1.3667340 -0.6031376

&gt; temp%&gt;%group_by(ID)%&gt;%summarize_each(funs(mean))
Source: local data frame [2 x 4]

     ID gender       val1       val2
  (dbl)  (lgl)      (dbl)      (dbl)
1     1     NA -0.7003184 -0.1595886
2     2     NA  0.5238282 -0.1405398
</code></pre>

<p>This doesn't work because <code>mean(gender)</code> doesn't make sense. </p>

<p><strong>Question:</strong>
If all my non-numeric columns are characteristic of <code>ID</code>, thus are identical within each <code>ID</code>, can I somehow get <code>summarize_each</code> to return that 'unique' value? </p>

<pre><code>&gt; temp%&gt;%group_by(ID,gender)%&gt;%summarize_each(funs(mean))
Source: local data frame [2 x 4]
Groups: ID [?]

     ID gender       val1       val2
  (dbl) (fctr)      (dbl)      (dbl)
1     1      M -0.7003184 -0.1595886
2     2      F  0.5238282 -0.1405398
</code></pre>

<p>is the output that I want, but I somehow feel like this is doing unnecessary nested <code>group_by</code> because there really is nothing to group within <code>ID</code>.</p>