FantasyFootballAnalytics / ffanalytics

ffanalytics R package
http://ffanalytics.fantasyfootballanalytics.net/
153 stars 100 forks source link

add_adp() error #143

Closed mwr824 closed 11 months ago

mwr824 commented 11 months ago

Using the add_adp() function results in the following error:

Error in `dplyr::transmute()`:
ℹ In argument: `id = get_mfl_id(player_name = name, team = team, pos = position)`.
Caused by error:
! object 'name' not found
Run `rlang::last_trace()` to see where the error occurred.
Warning message:
There was 1 warning in `dplyr::transmute()`.
ℹ In argument: `bye_week = as.integer(bye_week)`.
Caused by warning:
! NAs introduced by coercion

Steps to reproduce error:

library(ffanalytics)
library(tidyverse)

clear_ffanalytics_cache()

ff_data <- scrape_data(pos = c("QB", "RB", "WR", "TE", "DST", "K"),
            season = 2023, week = 0)

score_sets <- list(
  pass = list(
    pass_att = 0, pass_comp = 0, pass_inc = 0, pass_yds = 0.04, pass_tds = 4,
    pass_int = -1, pass_40_yds = 0,  pass_300_yds = 0, pass_350_yds = 0,
    pass_400_yds = 0
  ),
  rush = list(
    all_pos = TRUE,
    rush_yds = 0.1,  rush_att = 0, rush_40_yds = 0, rush_tds = 6,
    rush_100_yds = 0, rush_150_yds = 0, rush_200_yds = 0),
  rec = list(
    all_pos = TRUE,
    rec = 1, rec_yds = 0.1, rec_tds = 6, rec_40_yds = 0, rec_100_yds = 0,
    rec_150_yds = 0, rec_200_yds = 0
  ),
  misc = list(
    all_pos = TRUE,
    fumbles_lost = -2, fumbles_total = 0,
    sacks = 0, two_pts = 2
  ),
  kick = list(
    xp = 1.0, fg_0019 = 3.0,  fg_2029 = 3.0, fg_3039 = 3.0, fg_4049 = 4.0,
    fg_50 = 5.0,  fg_miss = 0.0
  ),
  ret = list(
    all_pos = TRUE,
    return_tds = 6, return_yds = 0
  ),
  idp = list(
    all_pos = TRUE,
    idp_solo = 1, idp_asst = 0.5, idp_sack = 2, idp_int = 3,  idp_fum_force = 3,
    idp_fum_rec = 2,  idp_pd = 1, idp_td = 6,  idp_safety = 2
  ),
  dst = list(
    dst_fum_rec = 2,  dst_int = 2, dst_safety = 2, dst_sacks = 1, dst_td = 6,
    dst_blk = 2, dst_ret_yds = 0, dst_pts_allowed = 0
  ),
  pts_bracket = list(
    list(threshold = 0, points = 10),
    list(threshold = 6, points = 7),
    list(threshold = 13, points = 4),
    list(threshold = 20, points = 1),
    list(threshold = 27, points = 0),
    list(threshold = 34, points = -1),
    list(threshold = 99, points = -4)
  )
)

ff_data |>
  projections_table(scoring_rules = score_sets) |>
  add_player_info() |> 
  add_ecr() |> 
  add_adp()
atungate commented 11 months ago

Thanks for lettings us know. It looks like the 2023 ADP data from Fantasy Football Calculator (https://fantasyfootballcalculator.com/adp) is down at the moment. I'll leave this issue open until I update the function to fail better (i.e., throw a warning but continue with the other sources)

For now you can just drop FFC from the sources:

get_adp(sources = c("RTS", "CBS", "Yahoo", "NFL", "MFL", "ESPN"))
# or in your pipe
add_adp(sources = c("RTS", "CBS", "Yahoo", "NFL", "MFL", "ESPN"))

In-general and not your specific question, but we don't recommend scraping past weeks of data because sites may or may not retain past weeks / seasonal projections. It is possible that the source being scrapes for week 0 is actually pulling data for the "rest of season". Different sources do different things but I wanted to let you know.

atungate commented 11 months ago

Should be good now--let me know if you continue to have issues with it (https://github.com/FantasyFootballAnalytics/ffanalytics/commit/d20f5bcabe30afab94587ae3c3297dab18a3c065)

mwr824 commented 11 months ago

That was quick, thank you!

And thanks for your comment about pulling prior weeks data. I was just getting myself familiar initially, but actually am now interested in pulling the rest of season projections to help with waiver wire selections. Do you happen to know off the top of your head which sources (by setting week = 0) provide those?