Suppose we are interested in listing the top FPL performers by FPL goals and assists? Again, we take the first 25 gameweeks of the 18/19 season as an example.
First we fetch the gameweek-by-gameweek details of ALL players using get_player_details:
library(fplscrapR) df <- get_player_details(season=18) # this may take a while to load as it fetches ALL player details
Next we use dplyr and ggplot2 to transform and plot the data, showing the top performers:
library(dplyr) library(ggplot2)
df %>% filter(round %in% 1:25) %>% # filtering for the GWs we are interested in select(playername,goals_scored,assists) %>% # selecting the relevant columns group_by(playername) %>% # transformation to group and summarize the performance at the 'playername' variable level summarize_all(sum) %>% mutate("involvements"=goals_scored+assists) %>% # adding a new variable that sums the goals scored and assists arrange(-involvements) %>% # ordering (arranging) the table by top involvements slice(1:20) # showing the top20 only
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.