Suppose now we are interested in finding the names of the goalscorers in a given game? Here we take the example of the first fixture of the season.
First we fetch the game stats using get_game_stats:
library(fplscrapR) df <- get_game_stats(gameid=1)
Next we identify the goalscorers' playerids:
goalscorerids <- unlist(list(df$a[[1]]$element,df$h[[1]]$element))
Finally we fetch the playernames of goalscorers using get_player_name:
get_player_name(playerid=goalscorerids)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.