Grouping and summing with r I have a data.frame that contains two columns that I want to group and sum the direct labor for employees.

Employees   Actual work
Joe Smo      8
Joe Smo      7
Joe Smo      5
Sam Adams    7
Sam Adams    5
Sam Adams    3


The desired outcome is

Results:
Joe Smo      20
Sam Adams    15


Here is the code I used that doesn't work.

aggregate(directLaborNov18[c('Employee')], directLaborNov18['Actual_work'], sum)
You were very close. Just switch the first two input arguments.

&gt; aggregate(directLaborNov18['Actual_work'], directLaborNov18[c('Employee')],  sum)
   Employee Actual_work
1   Joe Smo          20
2 Sam Adams          15