library(fflr)
packageVersion("fflr")
#> [1] '1.9.2'
ffl_id(leagueId = "42654852")
#> Temporarily set `fflr.leagueId` option to 42654852
#> [1] "42654852"
This vignette will demonstrate the fflr functions used to reach equivalency with the ESPN fantasy football website. The website has eight section headers with various subsections:
The My Team page presents an overview of, well, your fantasy team. From this page, a team manager can set their lineup and see statistics and news on the players on their roster.
There are six subsections on the My Team page.
The team_roster()
function returns all rosters in a league. The output of this function is organized to replicate the layout of the table found on the website. Players are listed in order of their “slot” with name and team information followed by projected and actual scores and ownership statistics.
<- team_roster(scoringPeriodId = 1)[[1]] # select first roster
my_team -(1:3)]
my_team[, #> # A tibble: 16 × 12
#> lineupSlot id firstName lastName proTeam position injuryStatus projectedScore
#> <fct> <int> <chr> <chr> <fct> <fct> <chr> <dbl>
#> 1 QB 3139477 Patrick Mahomes KC QB A 22.2
#> 2 RB 3117251 Christian McCaffrey Car RB O 21.3
#> 3 RB 4242335 Jonathan Taylor Ind RB A 15.6
#> 4 WR 16800 Davante Adams GB WR A 19.9
#> 5 WR 3925357 Calvin Ridley Atl WR A 16.0
#> 6 TE 3116365 Mark Andrews Bal TE A 12.2
#> 7 FX 4360294 Antonio Gibson Wsh RB A 16.0
#> 8 DS -16027 Buccaneers D/ST TB DS A 4.51
#> 9 PK 2473037 Jason Myers Sea PK A 8.04
#> 10 BE 4259545 D'Andre Swift Det RB A 13.5
#> 11 BE 4045163 Miles Sanders Phi RB A 14.3
#> 12 BE 3919596 Chris Carson Sea RB A 12.8
#> 13 BE 16799 Allen Robinson II Chi WR A 14.6
#> 14 BE 16460 Adam Thielen Min WR A 14.4
#> 15 BE 3932905 Diontae Johnson Pit WR A 13.4
#> 16 BE 3128429 Courtland Sutton Den WR A 11.9
#> # … with 4 more variables: actualScore <dbl>, percentStarted <dbl>, percentOwned <dbl>,
#> # percentChange <dbl>
The player_outlook()
and player_news()
functions return news on your roster. The first returns all outlooks by player and week and cannot be refined beyond setting a limit
of players to return (in order of rank).
player_outlook(limit = 1)
#> # A tibble: 5 × 6
#> seasonId scoringPeriodId id firstName lastName outlook
#> <int> <int> <int> <chr> <chr> <chr>
#> 1 2021 0 16800 Davante Adams Adams was the top-scoring fantasy WR …
#> 2 2021 1 16800 Davante Adams Last season, Adams was on pace for on…
#> 3 2021 2 16800 Davante Adams The Packers' offense simply couldn't …
#> 4 2021 3 16800 Davante Adams A rare blend of efficiency and volume…
#> 5 2021 4 16800 Davante Adams Another elite prime-time performance …
The second fiction takes a single playerId
value and returns all the recent news on that player, including premium stories in HTML format.
player_news(playerId = "3139477", parseHTML = FALSE)
#> # A tibble: 14 × 6
#> id published type premium headline body
#> <int> <dttm> <chr> <lgl> <chr> <chr>
#> 1 3139477 2021-10-03 20:37:42 Rotowire FALSE Mahomes completed 24 … "Mahomes capped Ka…
#> 2 3139477 2021-09-26 20:22:02 Rotowire FALSE Mahomes completed 27 … "Kansas City has s…
#> 3 3139477 2021-09-20 04:47:05 Rotowire FALSE Mahomes completed 24 … "Mahomes carved up…
#> 4 3139477 2021-09-17 23:13:41 Story FALSE NFL Week 2 game picks… "<p><video1></vide…
#> 5 3139477 2021-09-13 03:01:33 Rotowire FALSE Mahomes completed 27 … "The 25-year-old s…
#> 6 3139477 2021-09-10 14:36:05 Story TRUE NFL Week 1 prediction… "<p><video1></vide…
#> 7 3139477 2021-09-08 04:56:27 Story FALSE 'So, you're Patrick M… "<p><video1><br>\n…
#> 8 3139477 2021-08-31 14:15:41 Story TRUE Predicting NFL teams … "<p><video1></vide…
#> 9 3139477 2021-08-28 03:31:05 Rotowire FALSE Mahomes completed eig… "Mahomes was his s…
#> 10 3139477 2021-08-21 03:07:20 Rotowire FALSE Mahomes completed 10 … "There had been ta…
#> 11 3139477 2021-08-18 16:33:13 Rotowire FALSE Coach Andy Reid said … "Mahomes played on…
#> 12 3139477 2021-08-15 04:19:01 Rotowire FALSE Mahomes completed one… "Mahomes connected…
#> 13 3139477 2021-08-12 18:54:27 Rotowire FALSE Coach Andy Reid sugge… "Reid didn't actua…
#> 14 3139477 2021-07-23 18:55:35 Rotowire FALSE Mahomes doesn't antic… "This was expected…
ESPN fantasy leagues have their own unique settings and structure. This package has been tested for a very narrow subset of those possible settings.
league_info(leagueId = "42654852")
#> # A tibble: 1 × 6
#> id seasonId name isPublic size finalScoringPeriod
#> <int> <int> <chr> <lgl> <int> <int>
#> 1 42654852 2021 FFLR Test League TRUE 4 17
league_name()
#> [1] "FFLR Test League"
league_size()
#> # A tibble: 1 × 2
#> seasonId size
#> <int> <int>
#> 1 2021 4
str(league_status())
#> tibble [1 × 12] (S3: tbl_df/tbl/data.frame)
#> $ year : int 2021
#> $ isActive : logi TRUE
#> $ activatedDate : POSIXct[1:1], format: "2021-08-03 10:40:01"
#> $ scoringPeriodId : int 4
#> $ firstScoringPeriod : int 1
#> $ finalScoringPeriod : int 17
#> $ previousSeasons :List of 1
#> ..$ : list()
#> $ standingsUpdateDate : POSIXct[1:1], format: "2021-10-04 03:49:31"
#> $ teamsJoined : int 4
#> $ waiverLastExecutionDate: POSIXct[1:1], format: "2021-10-04 03:49:31"
#> $ waiverNextExecutionDate: POSIXct[1:1], format: NA
#> $ waiverProcessStatus :List of 1
#> ..$ :'data.frame': 1 obs. of 2 variables:
#> .. ..$ date : POSIXct[1:1], format: "2021-09-29"
#> .. ..$ status: int 2
draft_settings()
#> # A tibble: 1 × 13
#> seasonId auctionBudget availableDate date isTradingEnabled
#> <int> <chr> <dttm> <dttm> <lgl>
#> 1 2021 <NA> 2021-08-03 10:15:00 2021-08-03 11:15:00 FALSE
#> # … with 8 more variables: keeperCount <int>, keeperCountFuture <int>,
#> # keeperOrderType <chr>, leagueSubType <chr>, orderType <chr>, pickOrder <list>,
#> # timePerSelection <int>, type <chr>
roster_settings()
#> # A tibble: 1 × 8
#> seasonId isBenchUnlimited isUsingUndroppabl… lineupLocktimeT… lineupSlotCounts moveLimit
#> <int> <lgl> <lgl> <chr> <list> <int>
#> 1 2021 TRUE TRUE INDIVIDUAL_GAME <df [25 × 2]> -1
#> # … with 2 more variables: positionLimits <list>, rosterLocktimeType <chr>
scoring_settings()
#> # A tibble: 1 × 7
#> seasonId scoringType playerRankType homeTeamBonus playoffHomeTeamBonus playoffMatchupTi…
#> <int> <chr> <chr> <int> <int> <chr>
#> 1 2021 H2H_POINTS PPR 1 0 NONE
#> # … with 1 more variable: scoringItems <list>
acquisition_settings()
#> # A tibble: 1 × 10
#> year acquisitionBudget acquisitionLimit acquisitionType isUsingAcquisition… minimumBid
#> <int> <int> <int> <chr> <lgl> <int>
#> 1 2021 100 -1 WAIVERS_TRADITI… FALSE 1
#> # … with 4 more variables: waiverHours <int>, waiverOrderReset <lgl>,
#> # waiverProcessDays <list>, waiverProcessHour <int>
schedule_settings()
#> # A tibble: 1 × 10
#> seasonId divisions matchupPeriodCount matchupPeriodLength matchupPeriods periodTypeId
#> <int> <list> <int> <int> <list> <int>
#> 1 2021 <df [2 × 3]> 17 1 <df [17 × 2]> 1
#> # … with 4 more variables: playoffMatchupPeriodLength <int>, playoffSeedingRule <chr>,
#> # playoffSeedingRuleBy <int>, playoffTeamCount <int>
league_members()
#> # A tibble: 1 × 3
#> displayName id isLeagueManager
#> <chr> <chr> <lgl>
#> 1 K5cents {22DFE7FF-9DF2-4F3B-9FE7-FF9DF2AF3BD2} FALSE
team_roster(scoringPeriodId = 1)
#> [[1]]
#> # A tibble: 16 × 15
#> seasonId scoringPeriodId teamId lineupSlot id firstName lastName proTeam position
#> <int> <int> <int> <fct> <int> <chr> <chr> <fct> <fct>
#> 1 2021 1 1 QB 3139477 Patrick Mahomes KC QB
#> 2 2021 1 1 RB 3117251 Christian McCaffr… Car RB
#> 3 2021 1 1 RB 4242335 Jonathan Taylor Ind RB
#> 4 2021 1 1 WR 16800 Davante Adams GB WR
#> 5 2021 1 1 WR 3925357 Calvin Ridley Atl WR
#> 6 2021 1 1 TE 3116365 Mark Andrews Bal TE
#> 7 2021 1 1 FX 4360294 Antonio Gibson Wsh RB
#> 8 2021 1 1 DS -16027 Buccaneers D/ST TB DS
#> 9 2021 1 1 PK 2473037 Jason Myers Sea PK
#> 10 2021 1 1 BE 4259545 D'Andre Swift Det RB
#> 11 2021 1 1 BE 4045163 Miles Sanders Phi RB
#> 12 2021 1 1 BE 3919596 Chris Carson Sea RB
#> 13 2021 1 1 BE 16799 Allen Robinso… Chi WR
#> 14 2021 1 1 BE 16460 Adam Thielen Min WR
#> 15 2021 1 1 BE 3932905 Diontae Johnson Pit WR
#> 16 2021 1 1 BE 3128429 Courtland Sutton Den WR
#> # … with 6 more variables: injuryStatus <chr>, projectedScore <dbl>, actualScore <dbl>,
#> # percentStarted <dbl>, percentOwned <dbl>, percentChange <dbl>
#>
#> [[2]]
#> # A tibble: 16 × 15
#> seasonId scoringPeriodId teamId lineupSlot id firstName lastName proTeam position
#> <int> <int> <int> <fct> <int> <chr> <chr> <fct> <fct>
#> 1 2021 1 2 QB 2577417 Dak Prescott Dal QB
#> 2 2021 1 2 RB 3116593 Dalvin Cook Min RB
#> 3 2021 1 2 RB 3051392 Ezekiel Elliott Dal RB
#> 4 2021 1 2 WR 3116406 Tyreek Hill KC WR
#> 5 2021 1 2 WR 4047650 DK Metcalf Sea WR
#> 6 2021 1 2 TE 3040151 George Kittle SF TE
#> 7 2021 1 2 FX 3128720 Nick Chubb Cle RB
#> 8 2021 1 2 DS -16023 Steelers D/ST Pit DS
#> 9 2021 1 2 PK 16339 Brandon McManus Den PK
#> 10 2021 1 2 BE 4242214 Clyde Edwards-… KC RB
#> 11 2021 1 2 BE 3121422 Terry McLaurin Wsh WR
#> 12 2021 1 2 BE 2976499 Amari Cooper Dal WR
#> 13 2021 1 2 BE 4039359 Darrell Henderso… LAR RB
#> 14 2021 1 2 BE 13982 Julio Jones Ten WR
#> 15 2021 1 2 BE 2977187 Cooper Kupp LAR WR
#> 16 2021 1 2 BE 2974858 Kenny Golladay NYG WR
#> # … with 6 more variables: injuryStatus <chr>, projectedScore <dbl>, actualScore <dbl>,
#> # percentStarted <dbl>, percentOwned <dbl>, percentChange <dbl>
#>
#> [[3]]
#> # A tibble: 16 × 15
#> seasonId scoringPeriodId teamId lineupSlot id firstName lastName proTeam position
#> <int> <int> <int> <fct> <int> <chr> <chr> <fct> <fct>
#> 1 2021 1 3 QB 3918298 Josh Allen Buf QB
#> 2 2021 1 3 RB 3929630 Saquon Barkley NYG RB
#> 3 2021 1 3 RB 3043078 Derrick Henry Ten RB
#> 4 2021 1 3 WR 15795 DeAndre Hopkins Ari WR
#> 5 2021 1 3 WR 4262921 Justin Jefferson Min WR
#> 6 2021 1 3 TE 2576925 Darren Waller LV TE
#> 7 2021 1 3 FX 3068267 Austin Ekeler LAC RB
#> 8 2021 1 0 DS -16033 Ravens D/ST Bal DS
#> 9 2021 1 3 PK 15683 Justin Tucker Bal PK
#> 10 2021 1 3 BE 3116385 Joe Mixon Cin RB
#> 11 2021 1 3 BE 15818 Keenan Allen LAC WR
#> 12 2021 1 3 BE 16737 Mike Evans TB WR
#> 13 2021 1 3 BE 4047365 Josh Jacobs LV RB
#> 14 2021 1 3 BE 3886818 Myles Gaskin Mia RB
#> 15 2021 1 3 BE 4362628 Ja'Marr Chase Cin WR
#> 16 2021 1 3 BE 4360438 Brandon Aiyuk SF WR
#> # … with 6 more variables: injuryStatus <chr>, projectedScore <dbl>, actualScore <dbl>,
#> # percentStarted <dbl>, percentOwned <dbl>, percentChange <dbl>
#>
#> [[4]]
#> # A tibble: 16 × 15
#> seasonId scoringPeriodId teamId lineupSlot id firstName lastName proTeam position
#> <int> <int> <int> <fct> <int> <chr> <chr> <fct> <fct>
#> 1 2021 1 4 QB 3917315 Kyler Murray Ari QB
#> 2 2021 1 4 RB 3054850 Alvin Kamara NO RB
#> 3 2021 1 4 RB 3042519 Aaron Jones GB RB
#> 4 2021 1 4 WR 2976212 Stefon Diggs Buf WR
#> 5 2021 1 4 WR 4047646 A.J. Brown Ten WR
#> 6 2021 1 4 TE 15847 Travis Kelce KC TE
#> 7 2021 1 4 FX 4241457 Najee Harris Pit RB
#> 8 2021 1 0 DS -16025 49ers D/ST SF DS
#> 9 2021 1 4 PK 3055899 Harrison Butker KC PK
#> 10 2021 1 4 BE 4035538 David Montgomery Chi RB
#> 11 2021 1 4 BE 4241985 J.K. Dobbins Bal RB
#> 12 2021 1 4 BE 15880 Robert Woods LAR WR
#> 13 2021 1 4 BE 4241389 CeeDee Lamb Dal WR
#> 14 2021 1 4 BE 3915416 DJ Moore Car WR
#> 15 2021 1 4 BE 3116165 Chris Godwin TB WR
#> 16 2021 1 4 BE 2577327 Tyler Lockett Sea WR
#> # … with 6 more variables: injuryStatus <chr>, projectedScore <dbl>, actualScore <dbl>,
#> # percentStarted <dbl>, percentOwned <dbl>, percentChange <dbl>
tidy_matchups(scoringPeriodId = 1)
#> # A tibble: 68 × 6
#> seasonId matchupPeriodId id teamId opponent home
#> <int> <int> <int> <fct> <fct> <lgl>
#> 1 2021 1 1 AUS CHI TRUE
#> 2 2021 1 1 CHI AUS FALSE
#> 3 2021 1 2 BOS DEN TRUE
#> 4 2021 1 2 DEN BOS FALSE
#> 5 2021 2 3 CHI DEN TRUE
#> 6 2021 2 3 DEN CHI FALSE
#> 7 2021 2 4 AUS BOS TRUE
#> 8 2021 2 4 BOS AUS FALSE
#> 9 2021 3 5 DEN AUS TRUE
#> 10 2021 3 5 AUS DEN FALSE
#> # … with 58 more rows
league_messages(scoringPeriodId = 1)
#> # A tibble: 3 × 7
#> id type author date content messages viewableBy
#> <chr> <chr> <chr> <dttm> <chr> <list> <list>
#> 1 a2d0d0b6 MSG_BOARD_GROUP {22DFE7F… 2021-09-13 19:46:29 "This is the… <df [2 … <NULL>
#> 2 1e760139 MSG_BOARD {22DFE7F… 2021-09-13 19:46:49 "This is the… <df [2 … <NULL>
#> 3 5af42ec9 NOTE {22DFE7F… 2021-09-13 19:46:07 "This [b]not… <NULL> <NULL>
transaction_counter()
#> # A tibble: 4 × 14
#> seasonId scoringPeriodId teamId abbrev waiverRank acquisitionBudgetS… acquisitions drops
#> <int> <int> <int> <fct> <int> <int> <int> <int>
#> 1 2021 4 1 AUS 1 0 0 0
#> 2 2021 4 2 BOS 2 0 0 0
#> 3 2021 4 3 CHI 4 0 2 2
#> 4 2021 4 4 DEN 3 0 2 1
#> # … with 6 more variables: misc <int>, moveToActive <int>, moveToIR <int>, paid <dbl>,
#> # teamCharges <dbl>, trades <int>
draft_recap()
#> # A tibble: 64 × 14
#> seasonId autoDraftTypeId bidAmount id keeper lineupSlotId nominatingTeamId
#> <int> <lgl> <int> <int> <lgl> <int> <fct>
#> 1 2021 TRUE NA 1 FALSE 2 <NA>
#> 2 2021 TRUE NA 2 FALSE 2 <NA>
#> 3 2021 TRUE NA 3 FALSE 2 <NA>
#> 4 2021 TRUE NA 4 FALSE 6 <NA>
#> 5 2021 TRUE NA 5 FALSE 2 <NA>
#> 6 2021 TRUE NA 6 FALSE 2 <NA>
#> 7 2021 TRUE NA 7 FALSE 2 <NA>
#> 8 2021 TRUE NA 8 FALSE 2 <NA>
#> 9 2021 TRUE NA 9 FALSE 4 <NA>
#> 10 2021 TRUE NA 10 FALSE 4 <NA>
#> # … with 54 more rows, and 7 more variables: overallPickNumber <int>, playerId <int>,
#> # reservedForKeeper <lgl>, roundId <int>, roundPickNumber <int>, teamId <fct>,
#> # tradeLocked <lgl>
recent_activity(scoringPeriodId = 1)
#> # A tibble: 66 × 13
#> id seaonId rating bidAmount scoringPeriodId memberId status fromLineupSlotId
#> <chr> <int> <int> <int> <int> <chr> <chr> <fct>
#> 1 062292e8 2021 0 NA 1 <NA> EXECUTED <NA>
#> 2 079a96a2 2021 0 NA 1 <NA> EXECUTED <NA>
#> 3 08e8044a 2021 0 NA 1 <NA> EXECUTED <NA>
#> 4 13b7c29a 2021 0 NA 1 <NA> EXECUTED <NA>
#> 5 172b6b5f 2021 0 NA 1 <NA> EXECUTED <NA>
#> 6 1b53d425 2021 0 NA 1 <NA> EXECUTED <NA>
#> 7 20d2e4a1 2021 0 NA 1 <NA> EXECUTED <NA>
#> 8 241ffb13 2021 0 NA 1 <NA> EXECUTED <NA>
#> 9 2460ef90 2021 0 NA 1 <NA> EXECUTED <NA>
#> 10 252e3cc0 2021 0 NA 1 <NA> EXECUTED <NA>
#> # … with 56 more rows, and 5 more variables: fromTeamId <int>, playerId <int>,
#> # toLineupSlotId <fct>, toTeamId <int>, type <chr>
all_players(limit = 10)
#> # A tibble: 10 × 19
#> seasonId scoringPeriodId id firstName lastName proTeam defaultPositionId
#> <int> <dbl> <int> <chr> <chr> <fct> <fct>
#> 1 2021 4 16800 Davante Adams GB WR
#> 2 2021 4 3116593 Dalvin Cook Min RB
#> 3 2021 4 15847 Travis Kelce KC TE
#> 4 2021 4 3043078 Derrick Henry Ten RB
#> 5 2021 4 3054850 Alvin Kamara NO RB
#> 6 2021 4 3116406 Tyreek Hill KC WR
#> 7 2021 4 2976212 Stefon Diggs Buf WR
#> 8 2021 4 3139477 Patrick Mahomes KC QB
#> 9 2021 4 15795 DeAndre Hopkins Ari WR
#> 10 2021 4 4047650 DK Metcalf Sea WR
#> # … with 12 more variables: injuryStatus <chr>, percentStarted <dbl>, percentOwned <dbl>,
#> # percentChange <dbl>, positionalRanking <int>, totalRating <dbl>,
#> # auctionValueAverage <dbl>, averageDraftPosition <dbl>, next_wk <dbl>, last_wk <dbl>,
#> # last_szn <dbl>, this_szn <dbl>
live_scoring()
#> # A tibble: 4 × 5
#> currentMatchupPeriod id teamId totalPointsLive totalProjectedPointsLive
#> <int> <int> <fct> <dbl> <dbl>
#> 1 4 7 CHI 147. 151.
#> 2 4 7 AUS 139. 139.
#> 3 4 8 DEN 105. 105.
#> 4 4 8 BOS 133. 133.
league_standings()
#> # A tibble: 4 × 19
#> seasonId scoringPeriodId teamId abbrev draftDayProjectedR… currentProjected… playoffSeed
#> <int> <int> <int> <fct> <int> <int> <int>
#> 1 2021 4 1 AUS 2 4 4
#> 2 2021 4 2 BOS 4 2 3
#> 3 2021 4 3 CHI 3 3 1
#> 4 2021 4 4 DEN 1 1 2
#> # … with 12 more variables: rankCalculatedFinal <int>, gamesBack <dbl>, losses <int>,
#> # percentage <dbl>, pointsAgainst <dbl>, pointsFor <dbl>, streakLength <int>,
#> # streakType <chr>, ties <int>, wins <int>, playoffPct <dbl>, divisionWinPct <dbl>