title: How to keep real values of grouped variable within dplyr package in R
body: <p>My data is something like this:</p>
  
  <pre><code> group &lt;- c(21, 21, 21, 9, 9, 9, 25, 25, 25)
   a &lt;- c(8,3,5,6,8,3,3,9,3)
   b &lt;- c(4,9,0,1,3,5,6,1,1)
   c &lt;- c(1,7,2,5,6,8,4,8,6)
   value &lt;- c(23,34,43,52,65,21,12,89,76)
   df &lt;- data.frame(group,a,b,c,value)
  </code></pre>
  
  <p>I applied following function to it. </p>
  
  <pre><code> out &lt;- df %&gt;%
     select(group, a, b, value) %&gt;%
     group_by(group = gl(n()/3, 3)) %&gt;%
     summarise(res = mean(value), a=a[1], b=b[1])
   print(out)
  </code></pre>
  
  <p>Then I am getting following result. </p>
  
  <pre><code> group   res     a     b
    &lt;fct&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;
  1  1      33.3     8     4
  2  2      46       6     1
  3  3      59       3     6
  &gt; 
  </code></pre>
  
  <p>My question is how to keep the orgiignal values of ID as they were in the output df like this </p>
  
  <pre><code> group   res     a     b
    &lt;fct&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;
  1  21      33.3     8     4
  2   9      46       6     1
  3  25      59       3     6
  &gt;
  </code></pre>
  
  <p>Thanks in advance!</p>