nflverse / nflreadr

Efficiently download nflverse data
https://nflreadr.nflverse.com/
Other
60 stars 13 forks source link

[BUG] Spread value in schedules is for the away team, not the home team #188

Closed andycancapital closed 1 year ago

andycancapital commented 1 year ago

Is there an existing issue for this?

Have you installed the latest development version of the package(s) in question?

What version of the package do you have?

1.0.2

Describe the bug

The data in load_schedules(seasons = TRUE) for the spread is incorrect. The value in the spread_line is not the home team spread but the away team spread value. I compared the value in this data to one I grabbed directly from PFR and it seems to be backwards

Reprex

NA

Expected Behavior

spread value should be the home teams value not the away teams value

nflverse_sitrep

── System Info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• R version 4.2.1 (2022-06-23)   • Running under: macOS Monterey 12.5
── nflverse Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• nflreadr (1.3.2.03)    • nflseedR (1.2.0)       • nflplotR (1.1.0.9006)  
• nflfastR (4.5.1.9001)  • nfl4th   (1.0.2.9006)  • nflverse (1.0.2)       
── nflverse Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
No options set for nflreadr, nflfastR, nflseedR, nfl4th, nflplotR, and nflverse
── nflverse Dependencies ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• askpass     (1.1)     • hms        (1.1.2)    • progressr    (0.11.0)   
• cachem      (1.0.6)   • httr       (1.4.4)    • proto        (1.0.0)    
• cli         (3.4.1)   • isoband    (0.2.5)    • purrr        (0.3.5)    
• codetools   (0.2-18)  • janitor    (2.1.0)    • R6           (2.5.1)    
• colorspace  (2.0-3)   • jsonlite   (1.8.3)    • rappdirs     (0.3.3)    
• cpp11       (0.4.3)   • labeling   (0.4.2)    • RColorBrewer (1.1-3)    
• crayon      (1.5.2)   • lattice    (0.20-45)  • Rcpp         (1.0.9)    
• curl        (4.3.3)   • lifecycle  (1.0.3)    • rlang        (1.0.6)    
• data.table  (1.14.2)  • listenv    (0.8.0)    • rstudioapi   (0.14)     
• digest      (0.6.30)  • lubridate  (1.8.0)    • scales       (1.2.0)    
• dplyr       (1.0.10)  • magick     (2.7.4)    • snakecase    (0.11.0)   
• fansi       (1.0.3)   • magrittr   (2.0.3)    • stringi      (1.7.8)    
• farver      (2.1.1)   • MASS       (7.3-57)   • stringr      (1.4.1)    
• fastmap     (1.1.0)   • Matrix     (1.4-1)    • sys          (3.4.1)    
• fastrmodels (1.0.2)   • memoise    (2.0.1)    • tibble       (3.1.8)    
• furrr       (0.3.1)   • mgcv       (1.8-40)   • tidyr        (1.2.1)    
• future      (1.28.0)  • mime       (0.12)     • tidyselect   (1.2.0)    
• generics    (0.1.3)   • munsell    (0.5.0)    • timechange   (0.2.0)    
• ggplot2     (3.3.6)   • nlme       (3.1-157)  • utf8         (1.2.2)    
• globals     (0.16.1)  • openssl    (2.0.4)    • vctrs        (0.4.2)    
• glue        (1.6.2)   • parallelly (1.32.1)   • viridisLite  (0.4.0)    
• gsubfn      (0.7)     • pillar     (1.8.1)    • withr        (2.5.0)    
• gtable      (0.3.0)   • pkgconfig  (2.0.3)    • xgboost      (1.6.0.1)

Screenshots

https://drive.google.com/file/d/1UHWC3kYu7W_4Osev-zL9ZS6O46HFh8QZ/view?usp=sharing

Additional context

You can review this dataset https://gist.github.com/andycancapital/e5aa284a92229e02fafb928875c28e80. season, week, home_team and spread_line are from the load_schedule() function and andy_home_team_vegas_line is from my internal dataset

andycancapital commented 1 year ago

Just re-read the documents, and it seems like this is expected but a bit confused given how spread values work. -4 usually means the home team is favored by 4 points and a positive value means the team is the underdog

guga31bb commented 1 year ago

Yes, this is expected behavior https://nflreadr.nflverse.com/articles/dictionary_pbp.html image