How to group a vector into a list of vectors?

后端 未结 4 2194
借酒劲吻你
借酒劲吻你 2020-12-06 19:13

I have some data which looks like this (fake data for example\'s sake):

dressId        color 
6              yellow 
9              red
10             green         


        
4条回答
  •  Happy的楠姐
    2020-12-06 19:38

    I am afraid that the answer should be a little different, you should use the following code to accomplish the requested behaviour

    df %>%
    group_by(dressId) %>%
    summarize(colors = toString(unique(color)))
    

提交回复
热议问题