nflverse / nflverse-pbp

builds play by play and player stats for nflverse/nflverse-data
Creative Commons Attribution 4.0 International
286 stars 63 forks source link

load_participation(include_pbp=TRUE) is not returning data for 2021 season LA-CIN Super Bowl #83

Closed numbersinfigures closed 11 months ago

numbersinfigures commented 11 months 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.3

Describe the bug

This is basically the fraternal twin to closed issue nflverse/nflfastR#77 in the nflverse-pbp repository. The participation only dataset includes the Rams/Bengals Super Bowl, but the nflverse_game_id logged as "2021_23_LA_CIN". It's omitted when "include_pbp=TRUE", since play-by-play dataset likely has the game tagged as "2021_22_LA_CIN".

I believe all the other available Super Bowls are now included in both requests post-fix.

Reprex

library(nflreadr)
library(tidyverse)

.clear_cache()

#NO PBP REQUESTED
wo_pbp <- load_participation(seasons = c(2021), include_pbp = FALSE) 

wo_pbp %>%
  dplyr::filter(nflverse_game_id == "2021_22_LA_CIN") %>%
  count(nflverse_game_id)
# A tibble: 0 x 2
# i 2 variables: nflverse_game_id <chr>, n <int>

wo_pbp %>%
  dplyr::filter(nflverse_game_id == "2021_23_LA_CIN") %>%
  count(nflverse_game_id)
# A tibble: 1 x 2
#  nflverse_game_id     n
#  <chr>            <int>
# 1 2021_23_LA_CIN     176

#PBP REQUESTED
with_pbp <-load_participation(seasons = c(2021), include_pbp = TRUE)

with_pbp %>%
  dplyr::filter(nflverse_game_id == "2021_22_LA_CIN") %>%
  count(nflverse_game_id)
# A tibble: 0 x 2
# i 2 variables: nflverse_game_id <chr>, n <int>

with_pbp %>%
  dplyr::filter(nflverse_game_id == "2021_23_LA_CIN") %>%
  count(nflverse_game_id)
# A tibble: 0 x 2
# i 2 variables: nflverse_game_id <chr>, n <int>

Expected Behavior

nflverse_sitrep

-- System Info ------------------------------------------------------------------------------
* R version 4.1.3 (2022-03-10) * Running under: Windows 10 x64 (build 19045)
-- Package Status ---------------------------------------------------------------------------
   package  installed  cran        dev behind
1   nfl4th 1.0.4.9001 1.0.4 1.0.4.9001       
2 nflfastR 4.5.1.9013 4.5.1 4.5.1.9013       
3 nflplotR 1.2.0.9001 1.2.0 1.2.0.9001       
4 nflreadr   1.4.0.08 1.4.0   1.4.0.08       
5 nflseedR      1.2.0 1.2.0      1.2.0       
6 nflverse      1.0.3 1.0.3      1.0.3       
-- Package Options --------------------------------------------------------------------------
* No options set for above packages
-- Package Dependencies ---------------------------------------------------------------------
* askpass     (1.1)         * jsonlite     (1.8.4)     * sys         (3.4)      
* backports   (1.4.1)       * labeling     (0.4.2)     * tibble      (3.2.1)    
* cachem      (1.0.6)       * lifecycle    (1.0.3)     * tidyr       (1.3.0)    
* cli         (3.6.0)       * listenv      (0.8.0)     * tidyselect  (1.2.0)    
* colorspace  (2.0-3)       * lubridate    (1.9.2)     * timechange  (0.1.1)    
* cpp11       (0.4.3)       * magick       (2.7.3)     * utf8        (1.2.2)    
* crayon      (1.5.2)       * magrittr     (2.0.3)     * vctrs       (0.6.1)    
* curl        (5.0.0)       * MASS         (7.3-58.1)  * viridisLite (0.4.1)    
* data.table  (1.14.6)      * memoise      (2.0.1)     * withr       (2.5.0)    
* digest      (0.6.31)      * mime         (0.12)      * xgboost     (1.6.0.1)  
* dplyr       (1.1.2)       * munsell      (0.5.0)     * codetools   (0.2-18)   
* ellipsis    (0.3.2)       * openssl      (2.0.0)     * compiler    (4.1.3)    
* fansi       (1.0.3)       * parallelly   (1.33.0)    * graphics    (4.1.3)    
* farver      (2.1.1)       * pillar       (1.9.0)     * grDevices   (4.1.3)    
* fastmap     (1.1.0)       * pkgconfig    (2.0.3)     * grid        (4.1.3)    
* fastrmodels (1.0.2.9001)  * progressr    (0.12.0)    * lattice     (0.20-45)  
* furrr       (0.2.3)       * proto        (1.0.0)     * MASS        (7.3-55)   
* future      (1.29.0)      * purrr        (1.0.1)     * Matrix      (1.4-0)    
* generics    (0.1.3)       * R6           (2.5.1)     * methods     (4.1.3)    
* ggpath      (1.0.1)       * rappdirs     (0.3.3)     * mgcv        (1.8-39)   
* ggplot2     (3.4.2)       * RColorBrewer (1.1-3)     * nlme        (3.1-155)  
* globals     (0.16.2)      * Rcpp         (1.0.11)    * parallel    (4.1.3)    
* glue        (1.6.2)       * rlang        (1.1.0)     * splines     (4.1.3)    
* gsubfn      (0.7)         * rstudioapi   (0.14)      * stats       (4.1.3)    
* gtable      (0.3.4)       * scales       (1.2.1)     * tools       (4.1.3)    
* httr        (1.4.6)       * snakecase    (0.11.0)    * utils       (4.1.3)    
* isoband     (0.2.6)       * stringi      (1.7.6)       
* janitor     (2.1.0)       * stringr      (1.5.0)       
---------------------------------------------------------------------------------------------

Screenshots

No response

Additional context

No response

mrcaseb commented 11 months ago

I think this is caused by a typo in the logics here https://github.com/nflverse/nflverse-pbp/blob/e7547cd92edf747a1b847082e33c880f4ed229e0/R/update_pbp_participation.R#L14-L15 and here https://github.com/nflverse/nflverse-pbp/blob/e7547cd92edf747a1b847082e33c880f4ed229e0/R/update_pbp_participation.R#L42-L43

grafik

Logic should be

week = dplyr::case_when(
  !!season < 2021  & week == 22 ~ 21,
  !!season >= 2021 & week == 23 ~ 22,
  TRUE ~ week
)