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
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
Any advice?
You can use
ave
andpaste
:Or plyr: