0

我有这样的数据:

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

我现在想按 id 对它们进行分组,然后用逗号列出 shop_id,如下所示:

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

最实用的方法是什么?

4

0 回答 0