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
##                       playername is_captain is_vice_captain ep_next
## 1                 Robert Sánchez      FALSE           FALSE     2.3
## 2                      Luke Shaw      FALSE           FALSE     3.1
## 3         Trent Alexander-Arnold      FALSE           FALSE     5.0
## 4          Konstantinos Tsimikas      FALSE           FALSE     2.0
## 5                  Harvey Barnes      FALSE           FALSE     2.4
## 6                  Mohamed Salah       TRUE           FALSE     5.0
## 7  Bruno Miguel Borges Fernandes      FALSE            TRUE     4.4
## 8                Mason Greenwood      FALSE           FALSE     3.0
## 9           Raphael Dias Belloli      FALSE           FALSE     2.2
## 10               Michail Antonio      FALSE           FALSE     2.4
## 11                    Danny Ings      FALSE           FALSE     3.0
## 12                    Ben Foster      FALSE           FALSE     0.5
## 13                     Ben White      FALSE           FALSE     1.7
## 14                   Luke Ayling      FALSE           FALSE     1.7
## 15                  Stipe Perica      FALSE           FALSE     0.5
sum(df2$ep_next[1:11])
## [1] 34.8