0

I have a table like this:

col_1  col_2
1      a
1      b
1      c
2      a
2      b

and would like to convert to this:

col_1  col_2
1      a,b,c
2      a,b

What's the simplest way of doing this? I've tried playing around with tidyverse package but can't get my head around it.

Thanks

reaker
  • 145
  • 1
  • 9
  • 1
    Try `aggregate(col_2 ~ col_1, df1, toString)` or `library(dplyr); df1 %>% group_by(col_1) %>% summarise(col_2 = paste(col_2, collapse=","))` – akrun Oct 16 '18 at 16:58
  • 2
    I wonder how many duplicates of this question are in SO? – IRTFM Oct 16 '18 at 17:07

0 Answers0