1. <tfoot id='7PRj5'></tfoot>
      2. <small id='7PRj5'></small><noframes id='7PRj5'>

        <legend id='7PRj5'><style id='7PRj5'><dir id='7PRj5'><q id='7PRj5'></q></dir></style></legend>
        <i id='7PRj5'><tr id='7PRj5'><dt id='7PRj5'><q id='7PRj5'><span id='7PRj5'><b id='7PRj5'><form id='7PRj5'><ins id='7PRj5'></ins><ul id='7PRj5'></ul><sub id='7PRj5'></sub></form><legend id='7PRj5'></legend><bdo id='7PRj5'><pre id='7PRj5'><center id='7PRj5'></center></pre></bdo></b><th id='7PRj5'></th></span></q></dt></tr></i><div id='7PRj5'><tfoot id='7PRj5'></tfoot><dl id='7PRj5'><fieldset id='7PRj5'></fieldset></dl></div>
          <bdo id='7PRj5'></bdo><ul id='7PRj5'></ul>

        在 R 中按组连接列

        时间:2023-10-25
          <tbody id='oijsd'></tbody>

          • <bdo id='oijsd'></bdo><ul id='oijsd'></ul>

            • <tfoot id='oijsd'></tfoot>
            • <legend id='oijsd'><style id='oijsd'><dir id='oijsd'><q id='oijsd'></q></dir></style></legend>

              <i id='oijsd'><tr id='oijsd'><dt id='oijsd'><q id='oijsd'><span id='oijsd'><b id='oijsd'><form id='oijsd'><ins id='oijsd'></ins><ul id='oijsd'></ul><sub id='oijsd'></sub></form><legend id='oijsd'></legend><bdo id='oijsd'><pre id='oijsd'><center id='oijsd'></center></pre></bdo></b><th id='oijsd'></th></span></q></dt></tr></i><div id='oijsd'><tfoot id='oijsd'></tfoot><dl id='oijsd'><fieldset id='oijsd'></fieldset></dl></div>

              <small id='oijsd'></small><noframes id='oijsd'>

                  本文介绍了在 R 中按组连接列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设我有这个员工列表:

                  Suppose I've got this employee list:

                   Dept Date      Name            
                  ----- --------- --------------- 
                     30 07-DEC-02 Raphaely        
                     30 18-MAY-03 Khoo            
                     40 07-JUN-02 Mavris          
                     50 01-MAY-03 Kaufling        
                     50 14-JUL-03 Ladwig          
                     70 07-JUN-02 Baer            
                     90 13-JAN-01 De Haan
                     90 17-JUN-03 King  
                    100 16-AUG-02 Faviet
                    100 17-AUG-02 Greenberg 
                    110 07-JUN-02 Gietz           
                    110 07-JUN-02 Higgins         
                  

                  我想要在 R 中按部门聚合列表(类似于 Oracle PL/SQL 的 LISTAGG 函数) 将生成最后一列:

                  I want a list aggregation by department in R (similar to Oracle PL/SQL's LISTAGG function) that would product this last column:

                   Dept Date      Name            Emp_list
                  ----- --------- --------------- ---------------------------------------------
                     30 07-DEC-02 Raphaely        Raphaely; Khoo
                     30 18-MAY-03 Khoo            Raphaely; Khoo
                     40 07-JUN-02 Mavris          Mavris
                     50 01-MAY-03 Kaufling        Kaufling; Ladwig
                     50 14-JUL-03 Ladwig          Kaufling; Ladwig
                     70 07-JUN-02 Baer            Baer
                     90 13-JAN-01 De Haan         De Haan; King
                     90 17-JUN-03 King            De Haan; King
                    100 16-AUG-02 Faviet          Faviet; Greenberg
                    100 17-AUG-02 Greenberg       Faviet; Greenberg
                    110 07-JUN-02 Gietz           Gietz; Higgins
                    110 07-JUN-02 Higgins         Gietz; Higgins
                  

                  有什么建议吗?

                  推荐答案

                  可以使用avepaste:

                  within(mydf, {
                    Emp_list <- ave(Name, Dept, FUN = function(x) paste(x, collapse = "; "))
                  })
                  #   Dept      Date      Name          Emp_list
                  # 1    30 07-DEC-02  Raphaely    Raphaely; Khoo
                  # 2    30 18-MAY-03      Khoo    Raphaely; Khoo
                  # 3    40 07-JUN-02    Mavris            Mavris
                  # 4    50 01-MAY-03  Kaufling  Kaufling; Ladwig
                  # 5    50 14-JUL-03    Ladwig  Kaufling; Ladwig
                  # 6    70 07-JUN-02      Baer              Baer
                  # 7    90 13-JAN-01   De Haan     De Haan; King
                  # 8    90 17-JUN-03      King     De Haan; King
                  # 9   100 16-AUG-02    Faviet Faviet; Greenberg
                  # 10  100 17-AUG-02 Greenberg Faviet; Greenberg
                  # 11  110 07-JUN-02     Gietz    Gietz; Higgins
                  # 12  110 07-JUN-02   Higgins    Gietz; Higgins
                  

                  这篇关于在 R 中按组连接列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:以编程方式更新 Woocommerce 订单 下一篇:Mysql根据逻辑在存储过程中动态构建查询字符串

                  相关文章

                  <legend id='3ftN8'><style id='3ftN8'><dir id='3ftN8'><q id='3ftN8'></q></dir></style></legend>
                    <i id='3ftN8'><tr id='3ftN8'><dt id='3ftN8'><q id='3ftN8'><span id='3ftN8'><b id='3ftN8'><form id='3ftN8'><ins id='3ftN8'></ins><ul id='3ftN8'></ul><sub id='3ftN8'></sub></form><legend id='3ftN8'></legend><bdo id='3ftN8'><pre id='3ftN8'><center id='3ftN8'></center></pre></bdo></b><th id='3ftN8'></th></span></q></dt></tr></i><div id='3ftN8'><tfoot id='3ftN8'></tfoot><dl id='3ftN8'><fieldset id='3ftN8'></fieldset></dl></div>
                      <bdo id='3ftN8'></bdo><ul id='3ftN8'></ul>

                  1. <tfoot id='3ftN8'></tfoot>

                    <small id='3ftN8'></small><noframes id='3ftN8'>