I have a very large dataset with employers, employees and salaries. Each employee has a salary and is linked to an employer. Employers can have hundreds, even thousands of employees working for them. I want to find the average salary per employer. ie, I want to return an output with just 1 line per employer with an average salary based on all the employees they have. Thanks
Asked
Active
Viewed 429 times
1 Answers
1
You can use aggregate
for this:
aggregate(salaries, by = list(employers), FUN = mean)

Christopher Louden
- 7,540
- 2
- 26
- 29
-
Thanks - this works! as you can tell, I'm new to R and also these forums. apologises if I don't know the rules... – Nottles82 Mar 12 '14 at 10:27