title: Concatenating strings using group_by and summarise in r
body: <p>I am trying to concatenate a column of strings together based on a grouping. I'm using code that seems identical to me to what others have used (e.g. <a href="https://stackoverflow.com/questions/28752805/use-dplyr-to-concatenate-a-column">use dplyr to concatenate a column</a>) but it isn't working, and I can't figure out why.</p>
  
  <pre><code>a = tibble(
         x = c(1,2,1,2),
         z = c('1','2','3','4')
     )
  
  a %&gt;% group_by(x) %&gt;% summarise(val=paste(z, collapse=" "))
  </code></pre>
  
  <p>Gives:</p>
  
  <pre><code>   val
  1 1 2 3 4
  </code></pre>
  
  <p>It acts as if there was only one group. Yet when I do a different function, the grouping works properly:</p>
  
  <pre><code>a %&gt;% group_by(x) %&gt;% tally()
  # A tibble: 2 × 2
        x     n
    &lt;dbl&gt; &lt;int&gt;
  1     1     2
  2     2     2
  </code></pre>
  
  <p>Any idea what the issue might be?</p>