I'm fairly new to R and I'm trying to write a script for what I used to do with Solver in Excel. In my data below, I have a list of workers with job types A-E. Each worker has a salary and a production rate. What I want R to do is find the maximum production I can get from 10 workers with a cumulative salary <100,000. The restraints are that I need an exact total of 10 workers and I need 2 from job types A-D, 1 from E, and 1 of any type.
I've searched and searched for a way to do this with optim, IpSolve, etc., but with my limited knowledge I have not had much luck.
Thank you for your help!
Name Pos Salary Producton
Joe A 12001 13.1
Jim A 17753 23.5
Jill A 11447 14.8
Brian A 11447 14.8
Sally B 2171 1.2
Nancy B 4537 2.1
Francis B 2840 1.8
Ace B 2840 1.8
Bill C 3818 1.6
Ted C 11447 0.1
Henry C 2000 1.1
Kyle C 3818 1.6
Sam D 11447 0.1
Trevor D 2000 1.1
John D 4317 11.7
Jerome D 2000 1.1
Rebecca E 3818 1.6
Sunny E 11447 0.1
Britt E 2000 1.1
Sara E 4317 11.7