FantasyFootballAnalytics / ffanalytics

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

Example Scrape no longer works #131

Closed 4pack closed 1 year ago

4pack commented 1 year ago

The example scrape no longer works and errors out. Below code was used directly in the R interpreter. Most recent GitHub version of the package used.

library("ffanalytics")
library("dplyr")
library("tidyr")

my_scrape <- scrape_data(src = c("CBS", "NFL", "NumberFire"), 
                         pos = c("QB", "RB", "WR", "TE", "DST"),
                         season = 2022, week = 0)
my_projections <-  projections_table(my_scrape)

The above code causes the below error:

Error in `mutate()`:
! Problem while computing `pass_tds = col_fun(pass_tds = pass_tds, pass_comp = pass_comp)`.
i The error occurred in group 65: id = "13638".
Caused by error in `derive_from_rate()`:
! object 'pass_comp' not found
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/dplyr:::mutate_error>
Error in `mutate()`:
! Problem while computing `pass_tds = col_fun(pass_tds = pass_tds, pass_comp = pass_comp)`.
i The error occurred in group 65: id = "13638".
Caused by error in `derive_from_rate()`:
! object 'pass_comp' not found
---
Backtrace:
  1. ffanalytics::projections_table(my_scrape)
 11. ffanalytics (local) col_fun(pass_tds = pass_tds, pass_comp = pass_comp)
 12. ffanalytics:::derive_from_rate(pass_tds, pass_comp)
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/dplyr:::mutate_error>
Error in `mutate()`:
! Problem while computing `pass_tds = col_fun(pass_tds = pass_tds, pass_comp = pass_comp)`.
i The error occurred in group 65: id = "13638".
Caused by error in `derive_from_rate()`:
! object 'pass_comp' not found
---
Backtrace:
     x
  1. +-ffanalytics::projections_table(my_scrape)
  2. | \-ffanalytics:::impute_via_rates_and_mean(data_result, scoring_objs)
  3. |   \-base::lapply(...)
  4. |     \-ffanalytics (local) FUN(X[[i]], ...)
  5. |       \-ffanalytics:::call_impute_fun(df, col)
  6. |         +-dplyr::mutate(df, `:=`(!!col, col_fun(!!!args)))
  7. |         \-dplyr:::mutate.data.frame(df, `:=`(!!col, col_fun(!!!args)))
  8. |           \-dplyr:::mutate_cols(.data, dplyr_quosures(...), caller_env = caller_env())
  9. |             +-base::withCallingHandlers(...)
 10. |             \-mask$eval_all_mutate(quo)
 11. +-ffanalytics (local) col_fun(pass_tds = pass_tds, pass_comp = pass_comp)
 12. | \-ffanalytics:::derive_from_rate(pass_tds, pass_comp)
 13. \-base::.handleSimpleError(...)
 14.   \-dplyr (local) h(simpleError(msg, call))
 15.     \-rlang::abort(...)
atungate commented 1 year ago

Ahh, thanks for flagging. We'll update the readme. That is misleading because we cannot scrape past weeks (only the current week), so we will fix that.