1

The question is how to reverse operation of separate_rows, as shown in Reverse summary to expand comma separated strings in dataframe

I just adopted the example but aims to realize the opposite purpose: the original data is

df <- tibble(group=c("cat","cat","cat","dog","dog","dog","horse","horse","horse"),
             value=c(1,1,1,2,2,2,3,3,3), 
             list=c("siamese", "burmese", "balinese", "corgi", "sheltie", "collie", "arabian", "friesian", "andalusian"))



  group value       list
1   cat     1    siamese
2   cat     1    burmese
3   cat     1   balinese
4   dog     2      corgi
5   dog     2    sheltie
6   dog     2     collie
7 horse     3    arabian
8 horse     3   friesian
9 horse     3 andalusian

what I want to do is:

  group value                        list
1   cat     1    siamese,burmese,balinese
2   dog     2        corgi,sheltie,collie
3 horse     3 arabian,friesian,andalusian
AdIan
  • 125
  • 1
  • 6

0 Answers0