Fantasy football (oops, soccer)
[This article was first published on Enterprise Software Doesn't Have to Suck, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Recently a colleague asked if I could use R/statistics to form a dream soccer team from a pool of soccer players, given basic player information like name, club, cost, points.Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The idea is to form a team with your preferred configuration of number of defenders, mid fielders and strikers to maximize your total team points without exceeding your budget.
I wrote some R code (linear optimization) to get the answer. Check it out. The code allows configurable constraints to let you create your own dream team.
1) Number of goalkeepers
2) Number of defenders
3) Number of mid fielders
4) Number of strikers
5) Total team cost ($$$ you’ll spend on this team)
6) Maximum number of players from a team
Here’s a team I put together based on this code with following configuration.
1) Number of goalkeepers = 1
2) Number of defenders = 4
3) Number of mid fielders = 3
4) Number of strikers = 3
5) Total team cost = 50 GBP
6) Maximum number of players from a team = 4
DISCLAIMER: Soccer isn’t my favorite sport (its Cricket, if you’re curious 😉 and I don’t play fantasy football.
To leave a comment for the author, please follow the link and comment on their blog: Enterprise Software Doesn't Have to Suck.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.