nflverse / nflverse-rosters

builds roster data for nflverse/nflverse-data
Other
20 stars 3 forks source link

Filter for current roster #22

Closed soricinae closed 11 months ago

soricinae commented 2 years ago

I'd like to know which players are controlled by which teams right now. I want to exclude practice squad players and former players. The current data seems to include players who are on the practice squad or no longer on the roster. Maybe there could be a status column with values: active, IR, PUP, practice squad.

john-b-edwards commented 11 months ago

I think the best way to do this for now is to use load_rosters_weekly(), filter down to the most recent week, and then filter to Active. Other player statuses should be represented as well.

nflreadr::load_rosters_weekly() |>
    dplyr::filter(season == 2023) |>
    dplyr::filter(team == "SEA") |>
    dplyr::filter(week == 1) |>
    dplyr::filter(status == "Active") |>
    dplyr::arrange(full_name)
#> ── nflverse weekly roster data ─────────────────────────────────────────────────
#> ℹ Data updated: 2023-09-04 00:13:23 PDT
#> # A tibble: 54 × 36
#>    season team  position depth_chart_position jersey_number status full_name    
#>     <int> <chr> <chr>    <chr>                        <int> <chr>  <chr>        
#>  1   2023 SEA   OL       T                               72 Active Abraham Lucas
#>  2   2023 SEA   OL       G                               70 Active Anthony Brad…
#>  3   2023 SEA   LB       OLB                             48 Active Ben Burr-Kir…
#>  4   2023 SEA   LB       ILB                             54 Active Bobby Wagner 
#>  5   2023 SEA   LB       OLB                             53 Active Boye Mafe    
#>  6   2023 SEA   DL       NT                              93 Active Cameron Young
#>  7   2023 SEA   OL       T                               67 Active Charles Cross
#>  8   2023 SEA   SPEC     LS                              41 Active Chris Stoll  
#>  9   2023 SEA   DB       CB                               8 Active Coby Bryant  
#> 10   2023 SEA   WR       WR                              13 Active Cody Thompson
#> # ℹ 44 more rows
#> # ℹ 29 more variables: first_name <chr>, last_name <chr>, birth_date <date>,
#> #   height <int>, weight <int>, college <chr>, gsis_id <chr>, espn_id <chr>,
#> #   sportradar_id <chr>, yahoo_id <chr>, rotowire_id <chr>, pff_id <chr>,
#> #   pfr_id <chr>, fantasy_data_id <chr>, sleeper_id <chr>, years_exp <int>,
#> #   headshot_url <chr>, ngs_position <chr>, week <int>, game_type <chr>,
#> #   status_description_abbr <chr>, football_name <chr>, esb_id <chr>, …

This is not perfect, but generally correct -- Ben Burr-Kirven is included here despite being a free agent, I believe that's because he was released in the time since we last updated the weekly rosters.