-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathREADME.Rmd
125 lines (99 loc) · 3.77 KB
/
README.Rmd
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
warning = FALSE,
message = FALSE,
error = FALSE,
comment = "#>",
fig.path = "man/figures/README-",
fig.height = 4,
fig.width = 9,
out.width = "100%",
dpi = 300
)
if (!interactive()) {
options(width = 99)
}
```
# fflr <img src="man/figures/logo.png" align="right" width="120" />
<!-- badges: start -->
[![Lifecycle: experimental][life_badge]][life_link]
[![CRAN status][cran_badge]][cran_link]
![Downloads][dl_badge]
[![Codecov test coverage][cov_badge]][cov_link]
[![R build status][ga_badge]][ga_link]
<!-- badges: end -->
The fflr package is used to query the [ESPN Fantasy Football API][api]. Get data
on fantasy football league members, teams, and individual athletes.
This package has been tested with a narrow subset of possible league settings.
If a function doesn't work as intended, please file an [issue on GitHub][iss].
## Installation
> [!IMPORTANT]
> As of 2024-05-17, fflr was removed from [CRAN][cran] for failure to comply
with the policy on internet resources. This issue arose when ESPN changed their
API format and adjusted endpoints to account for the end of the 2023 NFL season.
I hope to work with CRAN to get the package published again before the 2024
season, but it may not be possible.
The most recent development version can always be installed from [GitHub][gh]:
```{r remote, eval=FALSE}
# install.packages("remotes")
remotes::install_github("k5cents/fflr")
```
## Usage
```{r library-fflr}
library(fflr)
packageVersion("fflr")
```
Data is only available for public leagues. See [this help page][help] on how to
make a private league public
Functions require a unique `leagueId`, which can be found in any ESPN page URL.
<pre>https://fantasy.espn.com/football/league?leagueId=<b>42654852</b></pre>
Use `ffl_id()` to set a default `fflr.leagueId` option. Your `.Rprofile` file
can [set this option on startup][rprof].
```{r rm-opt, echo=FALSE}
options(fflr.leagueId = NULL)
```
```{r ffl-id, message=TRUE}
ffl_id(leagueId = "42654852")
```
The `leagueId` argument defaults to `ffl_id()` and can be omitted once set.
```{r league-teams}
league_info()
league_teams()
```
The `scoringPeriodId` argument can be used to get data from past weeks.
```{r team-roster}
all_rost <- team_roster(scoringPeriodId = 1)
all_rost$CHI[, 5:13][-7]
```
There are included objects for NFL teams and players.
```{r nfl-players}
nfl_teams
```
> [!NOTE]
> The fflr project is released with a [Contributor Code of Conduct][coc]. By
contributing, you agree to abide by its terms.
<!-- refs: start -->
[life_badge]: https://img.shields.io/badge/lifecycle-stable-brightgreen.svg
[life_link]: https://lifecycle.r-lib.org/articles/stages.html#stable
[cran_badge]: https://www.r-pkg.org/badges/version/fflr
[cran_link]: https://CRAN.R-project.org/package=fflr
[ga_badge]: https://github.com/k5cents/fflr/workflows/R-CMD-check/badge.svg
[ga_link]: https://github.com/k5cents/fflr/actions
[cov_badge]: https://codecov.io/gh/k5cents/fflr/graph/badge.svg?token=CMz6DIxJdH
[cov_link]: https://app.codecov.io/gh/k5cents/fflr?branch=master
[dl_badge]: https://cranlogs.r-pkg.org/badges/grand-total/fflr
[api]: https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/
[iss]: https://github.com/k5cents/fflr/issues
[cran]: https://cran.r-project.org/package=fflr
[gh]: https://github.com/k5cents/fflr
[coc]: https://k5cents.github.io/fflr/CODE_OF_CONDUCT.html
[help]: https://web.archive.org/web/20211105212446/https://support.espn.com/hc/en-us/articles/360000064451-Making-a-Private-League-Viewable-to-the-Public
[rprof]: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html
<!-- refs: end -->