Skip to content
R package to query the ESPN fantasy football API 🏈
R
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
R
data-raw
data
man
pkgdown/favicon
tests
.Rbuildignore
.covrignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE.md
NAMESPACE
NEWS.md
README.Rmd
README.md
_pkgdown.yml
codecov.yml
cran-comments.md
fflr.Rproj

README.md

fflr

Lifecycle: experimental CRAN status Travis build status Codecov test coverage

The fflr package is used to query the ESPN Fantasy Football API, (for current and past seasons) and format the results into tidy data frames.

Installation

You can install the released version of fflr from GitHub with:

# install.packages("remotes")
remotes::install_github("kiernann/fflr")

Usage

Here we see how we can chain together fantasy_*() and form_*() functions to plot the weekly scores of each team in a stacked bar chart.

library(tidyverse)
library(fflr)

gaa <- extract_lid("https://fantasy.espn.com/football/league?leagueId=252353")
teams <- form_teams(data = fantasy_members(lid = gaa))
scores <- fantasy_matchup(lid = gaa) %>% 
  pluck("schedule") %>%
  map_df(form_matchup) %>% 
  right_join(teams) %>% 
  filter(score != 0)

scores %>% 
  ggplot(aes(x = reorder(abbrev, score), y = score)) +
  geom_col(aes(fill = week), position = position_stack(reverse = TRUE)) +
  labs(title = "Fantasy Football Scores", x = "Team", y = "Score") +
  guides(fill = guide_legend(nrow = 1)) +
  theme(legend.position = "bottom") +
  scale_fill_fantasy() +
  coord_flip()

Code of Conduct

Please note that the fflr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

You can’t perform that action at this time.