title: Data wrangling: Aggregating by group sequentially reducing
body: <p>I'm newbie to R. I need to aggregate the data by group with sequence. I'm adding my data frame. first two column is given data, I have to mutate third column.</p>
  
  <pre><code>df &lt;- data.frame(id = c(rep("a",3), rep("b",2), rep("c", 4)),
                 value = c("x", "z", "p", "q", "q", "m", "n", "x", "y"), 
                 reqd = c("x,z,p", "z,p", "p", "q,q","q", "m,n,x,y", "n,x,y", "x,y", "y"))
  </code></pre>
  
  <p>I had aggregated by group  but its not correct  </p>
  
  <pre><code>df_2 &lt;- df[,1:2]  %&gt;% 
  group_by(id) %&gt;% 
  mutate(reqd2 = paste(value, collapse = ","))
  </code></pre>