The FPL class is the main class used for interacting with Fantasy Premier League’s API.

Details

Information is taken from <https://fantasy.premierleague.com/api/bootstrap-static/>.

Public fields

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.

Active bindings

current_gameweek

`integer(1)`. The current gameweek.

Methods

Public methods


Method new()

Instantiate the `FPL` class.

Usage

FPL$new()

Returns

An R6 `FPL` object.

Examples

fpl <- FPL$new()


Method get_user()

Get information about a specific user.

Usage

FPL$get_user(user_id)

Arguments

user_id

`numeric(1)`. The user's id.

Returns

An R6 [User()] object.

Examples

fpl$get_user(555690)


Method get_team()

Get information about a specific team.

Usage

FPL$get_team(team_id)

Arguments

team_id

`numeric(1)`. The team's id.

Returns

An R6 `Team` object.

Examples

fpl$get_team(1)


Method get_teams()

Get information about specific teams.

Usage

FPL$get_teams(team_ids = NULL)

Arguments

team_ids

`numeric(n)`. The team ids.

Returns

A `list` of R6 [Team()] objects.

Examples

fpl$get_teams(1)


Method get_player()

Get information about a specific player.

Usage

FPL$get_player(player_id, include_summary = FALSE)

Arguments

player_id

`numeric(1)`. The player's id.

include_summary

`logical(1)`. Whether to include historical data and fixture details for the player.

Returns

An R6 [Player()] object.

Examples

fpl$get_player(1)


Method get_players()

Get information about multiple players.

Usage

FPL$get_players(player_ids = NULL, include_summary = FALSE)

Arguments

player_ids

`numeric(n)`. The player ids.

include_summary

`logical(1)`. Whether to include historical data and fixture details for the player.

Returns

A `list` of R6 [Player()] objects.

Examples

fpl$get_players(c(1, 10, 100))


Method get_player_summary()

Get historical and fixture information about a specific player.

Usage

FPL$get_player_summary(player_id)

Arguments

player_id

`numeric(1)`. The player's id.

Returns

An R6 [PlayerSummary()] object.

Examples

fpl$get_player_summary(1)


Method get_player_summaries()

Get historical and fixture information about multiple players.

Usage

FPL$get_player_summaries(player_id)

Arguments

player_id

`numeric(n)`. The player ids.

Returns

A `list` of R6 [PlayerSummary()] objects.

Examples

fpl$get_player_summaries(c(1, 10, 100))


Method get_points_against()

Get the points scored against all teams in the Premier League, split by position and location.

Usage

FPL$get_points_against()

Returns

A `data.frame` containing the opponent; the location of the scoring team; the position of the players; and the points scored against the opponent.

Examples

fpl$get_points_against()


Method 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.

Usage

FPL$get_fdr()

Returns

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.

Examples

fpl$get_fdr()


Method clone()

The objects of this class are cloneable with this method.

Usage

FPL$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

## ------------------------------------------------ ## 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.