nflverse-rosters
nflverse-rosters copied to clipboard
Incorrect season-weeks in `nflreadr::load_depth_charts(seasons = TRUE)`
Is there an existing issue for this?
- [X] I have searched the existing issues
Have you installed the latest development version of the package(s) in question?
- [x] I have installed the latest development version of the package.
If this is a data issue, have you tried clearing your nflverse cache?
I have cleared my nflverse cache and the issue persists.
What version of the package do you have?
1.4.0
Describe the bug
In 2001, week 5 and game_type = POST returns data for 31/32 teams, haven't checked which team is missing. Then, starting in 2007 with NE/NYG, week 5 and game_type = POST is the super bowl team's depth charts (i.e. all the way through 2023 where both SF/KC are charted this way, except 2014 seems to be without this bug).
In addition, the season weeks are just weird:
- 2001-04: weeks 1-21 are charted (correctly) but the playoff weeks have every team, not just the playoff teams
- 2005: data ends week 17
- 2006, 2014: seems right (weeks 1-21 charted and only teams in playoffs for 18-21)
- 2007-13, 2015-2020: week 18 is charted as like an extra fake regular season week for all teams, which pushes the subsequent weeks back one (i.e. the playoffs are now wrongly weeks 19-22)
- 2021-present: same thing as the bullet above except now the extra fake regular season week is week 19 and playoffs weeks 20-23
Reprex
r
library(nflreadr)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggplot2)
dc <- nflreadr::load_depth_charts(seasons = TRUE)
dplyr::count(subset(dc, week == 5 & game_type == "POST"), season, club_code) %>% View()
#> Error in check_for_XQuartz(): X11 library is missing: install XQuartz from xquartz.macosforge.org
subset(dplyr::count(dc, season, week), week >= 17) %>%
ggplot(aes(week, n)) +
geom_col() +
facet_wrap(~season)
Created on 2024-04-17 with reprex v2.1.0
### Expected Behavior
Would expect that depth charts should be charted only for the season-weeks that a team is actually playing in. If that is not possible for data reasons/issues/etc., would at least expect that the data be formatted the same across each season.
### nflverse_sitrep
```r
── System Info ────────────────────────────────────
• R version 4.1.2 (2021-11-01) • Running under: macOS 13.5
── Package Status ─────────────────────────────────
package installed cran dev behind
1 nfl4th 1.0.4 1.0.4 1.0.4.9002 dev
2 nflfastR 4.6.1 4.6.1 4.6.1.9008 dev
3 nflplotR 1.2.0 1.3.1 1.3.1 cran;dev
4 nflreadr 1.4.0 1.4.0 1.4.0.12 dev
5 nflseedR 1.2.0 1.2.0 1.2.0.9000 dev
── Package Options ────────────────────────────────
• No options set for above packages
── Package Dependencies ───────────────────────────
• askpass (1.2.0) • gtable (0.3.4) • proto (1.0.0)
• backports (1.4.1) • hms (1.1.3) • purrr (1.0.2)
• cachem (1.0.8) • httr (1.4.7) • R6 (2.5.1)
• cli (3.6.2) • isoband (0.2.7) • rappdirs (0.3.3)
• codetools (0.2-19) • janitor (2.2.0) • RColorBrewer (1.1-3)
• colorspace (2.1-0) • jsonlite (1.8.8) • Rcpp (1.0.12)
• compiler (4.1.2) • labeling (0.4.3) • rlang (1.1.3)
• cpp11 (0.4.7) • lattice (0.22-5) • scales (1.3.0)
• curl (5.2.0) • lifecycle (1.0.4) • snakecase (0.11.1)
• data.table (1.14.10) • listenv (0.9.1) • splines (4.1.2)
• digest (0.6.34) • lubridate (1.9.3) • stats (4.1.2)
• dplyr (1.1.4) • magick (2.8.2) • stringi (1.8.3)
• fansi (1.0.6) • magrittr (2.0.3) • stringr (1.5.1)
• farver (2.1.1) • MASS (7.3-60.0.1) • sys (3.4.2)
• fastmap (1.1.1) • Matrix (1.3-4) • tibble (3.2.1)
• fastrmodels (1.0.2) • memoise (2.0.1) • tidyr (1.3.1)
• furrr (0.3.1) • methods (4.1.2) • tidyselect (1.2.0)
• future (1.33.1) • mgcv (1.8-38) • timechange (0.3.0)
• generics (0.1.3) • mime (0.12) • tools (4.1.2)
• ggpath (1.0.1) • munsell (0.5.0) • utf8 (1.2.4)
• ggplot2 (3.4.4) • nlme (3.1-153) • utils (4.1.2)
• globals (0.16.2) • openssl (2.1.1) • vctrs (0.6.5)
• glue (1.7.0) • parallel (4.1.2) • viridisLite (0.4.2)
• graphics (4.1.2) • parallelly (1.36.0) • withr (3.0.0)
• grDevices (4.1.2) • pillar (1.9.0) • xgboost (1.7.7.1)
• grid (4.1.2) • pkgconfig (2.0.3)
• gsubfn (0.7) • progressr (0.14.0)
── Not Installed ──────────────────────────────────
• nflverse ()
───────────────────────────────────────────────────
Screenshots
No response
Additional context
No response