fantasysocceR

The players dataset contains summary data for individual players in the fantasy.premierleague.com game, the dataset was updated the day before the 2014/15 seasons started so there will be some changes due to players joining and leaving the game.

Once the package has been loaded, to access the dataset:

data(players)

The dataframe has dimensions 689 rows and 7 columns.

str(players)
## 'data.frame':    689 obs. of  7 variables:
##  $ id   : num  1 2 3 4 5 6 7 8 9 10 ...
##  $ name : chr  "Szczesny" "Ospina" "Cech" "Koscielny" ...
##  $ pos  : chr  "Goalkeeper" "Goalkeeper" "Goalkeeper" "Defender" ...
##  $ team : chr  "Arsenal" "Arsenal" "Arsenal" "Arsenal" ...
##  $ pts  : num  0 0 125 103 55 55 103 24 3 28 ...
##  $ value: num  5 4.7 5.9 6.3 5.2 4.3 6.1 5.2 5.1 4.9 ...
##  $ pct  : num  0 0.3 36.4 15.5 5.3 0.7 20.8 0.5 0.3 0.3 ...

There are 7 variables, the players position (‘pos’), their team, points scored last season (‘pts’), id number, name, value (when the package was created), and the percentage of teams the player is selected in (‘pct’)

A simple plot of this data to show the number of players in each position at each of the 20 clubs. We can also use the team_pal() function included in the package.

players$pos <- factor(players$pos, levels = c("Goalkeeper", "Defender",
                                              "Midfielder", "Forward"))
ggplot(players, aes(x=pos, fill=team)) +
    geom_bar() +
    theme_bw() +
    scale_fill_manual(values = team_pal()) +
    facet_wrap(~team)