Skip to contents

(Experimental!) This function reads your league's ff_scoring rules and maps them to nflfastr week-level data. Not all of the scoring rules from your league may have nflfastr equivalents, but most of the common ones are available!

Usage

ff_scoringhistory(conn, season, ...)

# S3 method for class 'espn_conn'
ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...)

# S3 method for class 'flea_conn'
ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...)

# S3 method for class 'mfl_conn'
ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...)

# S3 method for class 'sleeper_conn'
ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...)

# S3 method for class 'template_conn'
ff_scoringhistory(conn, season = 1999:nflreadr::most_recent_season(), ...)

Arguments

conn

a conn object created by ff_connect()

season

season a numeric vector of seasons (earliest available year is 1999)

...

other arguments

Value

A tidy dataframe of weekly fantasy scoring data, one row per player per week

Methods (by class)

  • ff_scoringhistory(espn_conn): ESPN: returns scoring history in a flat table, one row per player per week.

  • ff_scoringhistory(flea_conn): Fleaflicker: returns scoring history in a flat table, one row per player per week.

  • ff_scoringhistory(mfl_conn): MFL: returns scoring history in a flat table, one row per player per week.

  • ff_scoringhistory(sleeper_conn): Sleeper: returns scoring history in a flat table, one row per player per week.

  • ff_scoringhistory(template_conn): template: returns scoring history in a flat table, one row per player per week.

Examples

# \donttest{
try({ # try only shown here because sometimes CRAN checks are weird
  conn <- espn_connect(season = 2020, league_id = 899513)
  ff_scoringhistory(conn, season = 2020)
}) # end try
#> # A tibble: 5,957 × 37
#>    season  week gsis_id    sportradar_id  espn_id player_name pos   team  points
#>     <int> <int> <chr>      <chr>          <chr>   <chr>       <chr> <chr>  <dbl>
#>  1   2020     1 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB     20.5 
#>  2   2020     2 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB      8.68
#>  3   2020     3 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB     23.9 
#>  4   2020     4 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB     32.5 
#>  5   2020     5 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB     14.1 
#>  6   2020     6 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB     14.6 
#>  7   2020     7 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB     36.9 
#>  8   2020     8 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB     19.1 
#>  9   2020     9 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB      2.36
#> 10   2020    10 00-0019596 41c44740-d0f6… 2330    Tom Brady   QB    TB     31.8 
#> # ℹ 5,947 more rows
#> # ℹ 28 more variables: interceptions <dbl>, passing_2pt_conversions <dbl>,
#> #   passing_tds <dbl>, passing_yards <dbl>, receiving_2pt_conversions <dbl>,
#> #   receiving_fumbles_lost <dbl>, receiving_tds <dbl>, receiving_yards <dbl>,
#> #   receptions <dbl>, rushing_2pt_conversions <dbl>,
#> #   rushing_fumbles_lost <dbl>, rushing_tds <dbl>, rushing_yards <dbl>,
#> #   sack_fumbles_lost <dbl>, special_teams_tds <dbl>, fg_made_0_19 <dbl>, …
# }

# \donttest{
try({ # try only shown here because sometimes CRAN checks are weird
  conn <- fleaflicker_connect(2020, 312861)
  ff_scoringhistory(conn, season = 2020)
}) # end try
#> # A tibble: 5,400 × 24
#>    season  week gsis_id    sportradar_id  fleaflicker_id player_name pos   team 
#>     <int> <int> <chr>      <chr>          <chr>          <chr>       <chr> <chr>
#>  1   2020     1 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#>  2   2020     2 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#>  3   2020     3 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#>  4   2020     4 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#>  5   2020     5 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#>  6   2020     6 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#>  7   2020     7 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#>  8   2020     8 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#>  9   2020     9 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#> 10   2020    10 00-0019596 41c44740-d0f6… 309            Tom Brady   QB    TB   
#> # ℹ 5,390 more rows
#> # ℹ 16 more variables: points <dbl>, interceptions <dbl>,
#> #   passing_2pt_conversions <dbl>, passing_first_downs <dbl>,
#> #   passing_tds <dbl>, passing_yards <dbl>, receiving_2pt_conversions <dbl>,
#> #   receiving_first_downs <dbl>, receiving_tds <dbl>, receiving_yards <dbl>,
#> #   receptions <dbl>, rushing_2pt_conversions <dbl>, rushing_first_downs <dbl>,
#> #   rushing_tds <dbl>, rushing_yards <dbl>, special_teams_tds <dbl>
# }

# \donttest{
try({ # try only shown here because sometimes CRAN checks are weird
  ssb_conn <- ff_connect(platform = "mfl", league_id = 54040, season = 2020)
  ff_scoringhistory(ssb_conn, season = 2020)
}) # end try
#> # A tibble: 5,400 × 26
#>    season  week gsis_id    sportradar_id   mfl_id player_name pos   team  points
#>     <int> <int> <chr>      <chr>           <chr>  <chr>       <chr> <chr>  <dbl>
#>  1   2020     1 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     21.5 
#>  2   2020     2 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB      8.68
#>  3   2020     3 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     29.9 
#>  4   2020     4 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     40.5 
#>  5   2020     5 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     16.6 
#>  6   2020     6 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     18.6 
#>  7   2020     7 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     45.4 
#>  8   2020     8 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     23.1 
#>  9   2020     9 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     -3.64
#> 10   2020    10 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     38.3 
#> # ℹ 5,390 more rows
#> # ℹ 17 more variables: interceptions <dbl>, passing_2pt_conversions <dbl>,
#> #   passing_tds <dbl>, passing_yards <dbl>, receiving_2pt_conversions <dbl>,
#> #   receiving_fumbles_lost <dbl>, receiving_tds <dbl>, receiving_yards <dbl>,
#> #   receptions <dbl>, rushing_2pt_conversions <dbl>, rushing_first_downs <dbl>,
#> #   rushing_fumbles_lost <dbl>, rushing_tds <dbl>, rushing_yards <dbl>,
#> #   sack_fumbles_lost <dbl>, special_teams_tds <dbl>, …
# }

# \donttest{
try({ # try only shown here because sometimes CRAN checks are weird
  conn <- ff_connect(platform = "sleeper", league_id = "522458773317046272", season = 2020)
  ff_scoringhistory(conn, season = 2020)
}) # end try
#> # A tibble: 5,962 × 32
#>    season  week gsis_id  sportradar_id sleeper_id player_name pos   team  points
#>     <int> <int> <chr>    <chr>         <chr>      <chr>       <chr> <chr>  <dbl>
#>  1   2020     1 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB     20.5 
#>  2   2020     2 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB      8.68
#>  3   2020     3 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB     23.9 
#>  4   2020     4 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB     32.5 
#>  5   2020     5 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB     14.1 
#>  6   2020     6 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB     14.6 
#>  7   2020     7 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB     36.9 
#>  8   2020     8 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB     19.1 
#>  9   2020     9 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB      2.36
#> 10   2020    10 00-0019… 41c44740-d0f… 167        Tom Brady   QB    TB     31.8 
#> # ℹ 5,952 more rows
#> # ℹ 23 more variables: interceptions <dbl>, passing_2pt_conversions <dbl>,
#> #   passing_tds <dbl>, passing_yards <dbl>, receiving_2pt_conversions <dbl>,
#> #   receiving_fumbles_lost <dbl>, receiving_tds <dbl>, receiving_yards <dbl>,
#> #   receptions <dbl>, rushing_2pt_conversions <dbl>,
#> #   rushing_fumbles_lost <dbl>, rushing_tds <dbl>, rushing_yards <dbl>,
#> #   sack_fumbles_lost <dbl>, fg_made_0_19 <dbl>, fg_made_20_29 <dbl>, …
# }

# \donttest{
try({ # try only shown here because sometimes CRAN checks are weird
  template_conn <- ff_template(scoring_type = "sfb11", roster_type = "sfb11")
  ff_scoringhistory(template_conn, season = 2020)
}) # end try
#> # A tibble: 5,400 × 26
#>    season  week gsis_id    sportradar_id   mfl_id player_name pos   team  points
#>     <int> <int> <chr>      <chr>           <chr>  <chr>       <chr> <chr>  <dbl>
#>  1   2020     1 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     30.0 
#>  2   2020     2 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     22.2 
#>  3   2020     3 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     40.4 
#>  4   2020     4 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     55.5 
#>  5   2020     5 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     26.1 
#>  6   2020     6 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     27.1 
#>  7   2020     7 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     61.9 
#>  8   2020     8 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     35.1 
#>  9   2020     9 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB      4.36
#> 10   2020    10 00-0019596 41c44740-d0f6-… 5848   Tom Brady   QB    TB     51.3 
#> # ℹ 5,390 more rows
#> # ℹ 17 more variables: completions <dbl>, interceptions <dbl>,
#> #   passing_2pt_conversions <dbl>, passing_tds <dbl>, passing_yards <dbl>,
#> #   receiving_2pt_conversions <dbl>, receiving_tds <dbl>,
#> #   receiving_yards <dbl>, receptions <dbl>, rushing_2pt_conversions <dbl>,
#> #   rushing_first_downs <dbl>, rushing_tds <dbl>, rushing_yards <dbl>,
#> #   sacks <dbl>, special_teams_tds <dbl>, receiving_first_downs <dbl>, …
# }