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. use dplyr to concatenate a column) but it isn't working, and I can't figure out why.
a = tibble(
       x = c(1,2,1,2),
       z = c('1','2','3','4')
   )
a %>% group_by(x) %>% summarise(val=paste(z, collapse=" "))
Gives:
   val
1 1 2 3 4
It acts as if there was only one group. Yet when I do a different function, the grouping works properly:
a %>% group_by(x) %>% tally()
# A tibble: 2 × 2
      x     n
  <dbl> <int>
1     1     2
2     2     2
Any idea what the issue might be?