Have uploaded last season's #FPL week-by-week player data, as well as a fixture data to Dropbox. Good place to start if anyone's wanting to do some of their own analysis!
If anyone wants the link to download, drop me a message!
Hope this has been useful, my next two threads will probably be:
- Looking into all the different APIs that the FPL has available
- Starting to look into how we can analyse some of this data in R
If anyone has any issues at all with this guide, any questions, or any requests, then please get in touch!!
(10/10)
For now I’d recommend having a play around with this data in excel, see what you can find and what’s interesting!
You’ll notice some odd quirks, which we’ll work around in the future, such as there being no “position” column, instead it’s “element_type”.
(9/10)
That file should save by default to your “documents/R/“ folder, but if you can’t find it, run getwd() in your console and it should show you current working location.
Opening the file, we can now see all the data that FPL hold in the elements dataset, which currently contains all of last year’s summary data (this will change when the season starts). There are a lot of columns here, some are useful, some really aren’t!
(8/10)
Now for the fun stuff! Don’t worry about the details of the code for now, but try typing the following into your script, and pressing CTRL+ENTER line-by-line:
install.packages(c("curl", "jsonlite")
library(curl)
library(jsonlite)
url <- "https://fantasy.premierleague.com/api/bootstrap-static/"
url_connection <- curl(url)
data <- fromJSON(url_connection)
players <- data$elements
write.csv(players, file = "FPL_players.csv")
The screenshot gives explanations.
(7/10)
You should see this in your console window (the blue one from before).
This window shows outputs of code you run, but also allows you to type code line-by-line.
Let’s test this by typing 1+1 in the console, and pressing enter.
(6/10)
The red window is our scripts, this is where you can type a bunch of code, and save files. Here, you press CTRL+ENTER to run either the current line, or highlighted section.
Test this with print(“Hello World”), and then CTRL+ENTER (or click run in the top right)!
(5/10)