The FPL class is the main class used for interacting with Fantasy Premier League’s API.
Information is taken from <https://fantasy.premierleague.com/api/bootstrap-static/>.
events
A `data.frame`. Game week event data.
game_settings
A `list`. FPL game settings.
phases
A `data.frame`. Monthly gameweek information.
teams
A `data.frame`. Information pertaining to a Premier League team.
total_players
`integer(1)`. The total number of participants in FPL.
elements
A `data.frame`. The players data.
element_stats
A `data.frame`. Labels for certain stats based columns.
element_types
A `data.frame`. Squad position information.
current_gameweek
`integer(1)`. The current gameweek.
new()
Instantiate the `FPL` class.
FPL$new()
An R6 `FPL` object.
fpl <- FPL$new()
get_user()
Get information about a specific user.
FPL$get_user(user_id)
user_id
`numeric(1)`. The user's id.
An R6 [User()] object.
fpl$get_user(555690)
get_team()
Get information about a specific team.
FPL$get_team(team_id)
team_id
`numeric(1)`. The team's id.
An R6 `Team` object.
fpl$get_team(1)
get_teams()
Get information about specific teams.
FPL$get_teams(team_ids = NULL)
team_ids
`numeric(n)`. The team ids.
A `list` of R6 [Team()] objects.
fpl$get_teams(1)
get_player()
Get information about a specific player.
FPL$get_player(player_id, include_summary = FALSE)
player_id
`numeric(1)`. The player's id.
include_summary
`logical(1)`. Whether to include historical data and fixture details for the player.
An R6 [Player()] object.
fpl$get_player(1)
get_players()
Get information about multiple players.
FPL$get_players(player_ids = NULL, include_summary = FALSE)
player_ids
`numeric(n)`. The player ids.
include_summary
`logical(1)`. Whether to include historical data and fixture details for the player.
A `list` of R6 [Player()] objects.
fpl$get_players(c(1, 10, 100))
get_player_summary()
Get historical and fixture information about a specific player.
FPL$get_player_summary(player_id)
player_id
`numeric(1)`. The player's id.
An R6 [PlayerSummary()] object.
fpl$get_player_summary(1)
get_player_summaries()
Get historical and fixture information about multiple players.
FPL$get_player_summaries(player_id)
player_id
`numeric(n)`. The player ids.
A `list` of R6 [PlayerSummary()] objects.
fpl$get_player_summaries(c(1, 10, 100))
get_points_against()
Get the points scored against all teams in the Premier League, split by position and location.
FPL$get_points_against()
A `data.frame` containing the opponent; the location of the scoring team; the position of the players; and the points scored against the opponent.
fpl$get_points_against()
get_fdr()
Creates a new Fixture Difficulty Ranking (FDR) based on the number of points each team gives up to players in the Fantasy Premier League. These numbers are also between 1.0 and 5.0 to give a similar ranking system to the official FDR.
FPL$get_fdr()
A `data.frame` containing the opponent; the location of the scoring team; the player position; the fixture difficulty for the scoring player against the opponent.
fpl$get_fdr()
clone()
The objects of this class are cloneable with this method.
FPL$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------ ## Method `FPL$new` ## ------------------------------------------------ fpl <- FPL$new() ## ------------------------------------------------ ## Method `FPL$get_user` ## ------------------------------------------------ fpl$get_user(555690)#> [1] " - "## ------------------------------------------------ ## Method `FPL$get_team` ## ------------------------------------------------ fpl$get_team(1)#> [1] "Arsenal"## ------------------------------------------------ ## Method `FPL$get_teams` ## ------------------------------------------------ fpl$get_teams(1)#> [[1]] #> [1] "Arsenal" #>## ------------------------------------------------ ## Method `FPL$get_player` ## ------------------------------------------------ fpl$get_player(1)#> [1] "Özil"## ------------------------------------------------ ## Method `FPL$get_players` ## ------------------------------------------------ fpl$get_players(c(1, 10, 100))#> [[1]] #> [1] "Özil" #> #> [[2]] #> [1] "Marí" #> #> [[3]] #> [1] "McNeil" #>## ------------------------------------------------ ## Method `FPL$get_player_summary` ## ------------------------------------------------ fpl$get_player_summary(1)#> <PlayerSummary> #> Public: #> clone: function (deep = FALSE) #> fixtures: data.frame #> history: data.frame #> history_past: data.frame #> initialize: function (player_summary)## ------------------------------------------------ ## Method `FPL$get_player_summaries` ## ------------------------------------------------ fpl$get_player_summaries(c(1, 10, 100))#> [[1]] #> <PlayerSummary> #> Public: #> clone: function (deep = FALSE) #> fixtures: data.frame #> history: data.frame #> history_past: data.frame #> initialize: function (player_summary) #> #> [[2]] #> <PlayerSummary> #> Public: #> clone: function (deep = FALSE) #> fixtures: data.frame #> history: data.frame #> history_past: data.frame #> initialize: function (player_summary) #> #> [[3]] #> <PlayerSummary> #> Public: #> clone: function (deep = FALSE) #> fixtures: data.frame #> history: data.frame #> history_past: data.frame #> initialize: function (player_summary) #>## ------------------------------------------------ ## Method `FPL$get_points_against` ## ------------------------------------------------ fpl$get_points_against()#> Error in .deserialize_json(json = json, query = query, empty_array = empty_array, empty_object = empty_object, single_null = single_null, parse_error_ok = parse_error_ok, on_parse_error = on_parse_error, query_error_ok = query_error_ok, on_query_error = on_query_error, simplify_to = max_simplify_lvl, type_policy = type_policy, int64_r_type = int64_policy): The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.## ------------------------------------------------ ## Method `FPL$get_fdr` ## ------------------------------------------------ fpl$get_fdr()#> Error in .deserialize_json(json = json, query = query, empty_array = empty_array, empty_object = empty_object, single_null = single_null, parse_error_ok = parse_error_ok, on_parse_error = on_parse_error, query_error_ok = query_error_ok, on_query_error = on_query_error, simplify_to = max_simplify_lvl, type_policy = type_policy, int64_r_type = int64_policy): The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc.