vignettes/hazalexishist.Rmd
hazalexishist.Rmd
Suppose we are interested in how the FPL histories of Mesut Özil and Juan Mata compare?
First we fetch the player histories of those two players using get_player_hist, mobilising their playerids using get_player_id:
library(fplscrapR) df <- get_player_hist(playerid=get_player_id(c("Mesut Özil","Juan Mata"))$id)
Next we use dplyr and ggplot2 to transform and plot the data, showing the total FPL scores by season for the two players across their FPL careers:
df %>% select(playername,season_name,total_points) %>% # selecting the relevant columns ggplot() + # plotting using ggplot2 geom_line(aes(x=season_name,y=total_points,group=playername,colour=playername),size=1) + theme_bw() + labs(x="Season",y="Total score",title="Historical FPL season scores by Özil and Mata",caption=paste("Data from fplscrapR | ",Sys.Date(),sep=""))