1
$\begingroup$

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)
$\endgroup$
1
$\begingroup$

You were very close. Just switch the first two input arguments.

> aggregate(directLaborNov18['Actual_work'], directLaborNov18[c('Employee')],  sum)
   Employee Actual_work
1   Joe Smo          20
2 Sam Adams          15
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.