Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrape_team_stats_nfl gives error when role="defense" #21

Closed
bmacGTPM opened this issue Jun 12, 2023 · 2 comments
Closed

scrape_team_stats_nfl gives error when role="defense" #21

bmacGTPM opened this issue Jun 12, 2023 · 2 comments

Comments

@bmacGTPM
Copy link
Contributor

When I try this

scrape_team_stats_nfl(season = 2022, stats = "passing", role = "defense")

I get this error

Error in `purrr::set_names()`:
! The size of `nm` (15) must be compatible with the size of `x` (11).

A similar error occurs when stats is changed to rushing, scoring, or downs. When stats = "receiving", there is a different error. In particular, this code

scrape_team_stats_nfl(season = season, stats = "receiving", role = "defense")

gives this error

Error in rvest::html_table(raw_html, fill = TRUE)[[1]] : 
  subscript out of bounds

The code works well for all 5 choices of stats when role="offense". The errors only happen when role="defense".

@jthomasmock
Copy link
Owner

They changed the available columns for defense 👀

@jthomasmock
Copy link
Owner

Rolled up a new fix.

espnscrapeR::scrape_team_stats_nfl(season = 2022, role = "defense")
Scraping passing for defense from 2022!
# A tibble: 32 × 14
   season role    stat    team       pass_att pass_comp pass_comp_pct yds_att pass_yds pass_td   int first_downs
    <int> <chr>   <chr>   <chr>         <int>     <int>         <dbl>   <dbl>    <int>   <int> <int>       <int>
 1   2022 DEFENSE PASSING Buccaneer570       364         0.639     6.1     3461      29    10         186
 2   2022 DEFENSE PASSING ChargersC505       310         0.614     6.7     3406      24    14         175
 3   2022 DEFENSE PASSING VikingsVi617       408         0.661     7.3     4515      23    15         224
 4   2022 DEFENSE PASSING Cardinals593       414         0.698     6.6     3915      29    11         218
 5   2022 DEFENSE PASSING ChiefsChi619       408         0.659     6.1     3756      33    11         207
 6   2022 DEFENSE PASSING JetsJets        556       347         0.624     5.8     3220      15    12         166
 7   2022 DEFENSE PASSING BengalsBe559       329         0.589     6.6     3665      17    13         173
 8   2022 DEFENSE PASSING ColtsColts      537       365         0.68      6.6     3569      25    10         184
 9   2022 DEFENSE PASSING JaguarsJa601       385         0.641     6.8     4055      25    14         211
10   2022 DEFENSE PASSING LionsLions      560       353         0.63      7.5     4179      26    12         209
# ℹ 22 more rows
# ℹ 2 more variables: pass_first_pct <dbl>, sacks <int>
# ℹ Use `print(n = ...)` to see more rows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants