FPL: R6 Class representing the Fantasy Premier League's API

Description Details Public fields Active bindings Methods Examples

Description

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## ------------------------------------------------
## Method `FPL$new`
## ------------------------------------------------

fpl <- FPL$new()

## ------------------------------------------------
## Method `FPL$get_user`
## ------------------------------------------------

fpl$get_user(555690)


## ------------------------------------------------
## Method `FPL$get_team`
## ------------------------------------------------

fpl$get_team(1)


## ------------------------------------------------
## Method `FPL$get_teams`
## ------------------------------------------------

fpl$get_teams(1)


## ------------------------------------------------
## Method `FPL$get_player`
## ------------------------------------------------

fpl$get_player(1)


## ------------------------------------------------
## Method `FPL$get_players`
## ------------------------------------------------

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


## ------------------------------------------------
## Method `FPL$get_player_summary`
## ------------------------------------------------

fpl$get_player_summary(1)


## ------------------------------------------------
## Method `FPL$get_player_summaries`
## ------------------------------------------------

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


## ------------------------------------------------
## Method `FPL$get_points_against`
## ------------------------------------------------

fpl$get_points_against()


## ------------------------------------------------
## Method `FPL$get_fdr`
## ------------------------------------------------

fpl$get_fdr()

nathaneastwood/fpl documentation built on Nov. 22, 2020, 9:27 p.m.