0

I have data something like this:

df <- tribble(
  ~id,   ~shop_id,      
  "1",      10, 
  "2",      20,   
  "2",      30,   
  "3",      40, 
  "1",      50,   
)

I now want to group them by id, and then list shop_id with comma as below:

df <- tribble(
  ~id,   ~count_id_list,      
  "1",      10, 50,
  "2",      20, 30,  
  "3",      40,  
)

What is the most practical way to do this?

datazang
  • 783
  • 3
  • 10

0 Answers0