Suppose we are interested in how many points our team is expected to score in the next GW?
With fplscrapR, it's just a few lines of code away.
First, we fetch the player selection using get_entry_picks. Here I use the example of random team for GW2.
library(fplscrapR) picks <- get_entry_picks(entryid=1076,gw=1)$picks
Next we fetch the Official FPL Expected Points projections using get_player_info() and select only what we need: the player id (renamed 'element' for merging later), the player name, and the expected points projection ('ep_next'), which we indicate is a numeric vector.
library(dplyr) df <- get_player_info() %>% select(id,playername,ep_next) %>% mutate("element"=id) df$ep_next <- as.numeric(df$ep_next)
Finally we merge the two, select out the variables of interest, display the projections, and sum up the total expected points from our starting 11:
df2 <- left_join(picks,df,by="element") %>% select(playername,is_captain,is_vice_captain,ep_next) df2 sum(df2$ep_next[1:11])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.