Skip to contents

Loads play by play seasons from the nflverse-data repository

Usage

load_pbp(
  seasons = most_recent_season(),
  file_type = getOption("nflreadr.prefer", default = "rds")
)

Arguments

seasons

A numeric vector of 4-digit years associated with given NFL seasons - defaults to latest season. If set to TRUE, returns all available data since 1999.

file_type

One of c("rds", "qs", "csv", "parquet"). Can also be set globally with options(nflreadr.prefer)

Value

The complete nflfastR dataset as returned by nflfastR::build_nflfastR_pbp()

(see below) for all given seasons

See also

https://nflreadr.nflverse.com/articles/dictionary_pbp.html for a web version of the data dictionary

dictionary_pbp for the data dictionary bundled as a package dataframe

https://www.nflfastr.com/reference/build_nflfastR_pbp.html for the nflfastR function nflfastR::build_nflfastR_pbp()

Issues with this data should be filed here: https://github.com/nflverse/nflfastR-data

Examples

# \donttest{
try({ # prevents cran errors
  load_pbp(2019:2020)
})
#> ── nflverse play by play ───────────────────────────────────────────────────────
#>  Data updated: 2022-07-28 22:00:59 UTC
#> # A tibble: 96,548 × 372
#>    play_id game_id old_g…¹ home_…² away_…³ seaso…⁴  week posteam poste…⁵ defteam
#>      <dbl> <chr>   <chr>   <chr>   <chr>   <chr>   <int> <chr>   <chr>   <chr>  
#>  1       1 2019_0… 201909… MIN     ATL     REG         1 NA      NA      NA     
#>  2      36 2019_0… 201909… MIN     ATL     REG         1 ATL     away    MIN    
#>  3      51 2019_0… 201909… MIN     ATL     REG         1 ATL     away    MIN    
#>  4      79 2019_0… 201909… MIN     ATL     REG         1 ATL     away    MIN    
#>  5     100 2019_0… 201909… MIN     ATL     REG         1 ATL     away    MIN    
#>  6     121 2019_0… 201909… MIN     ATL     REG         1 ATL     away    MIN    
#>  7     148 2019_0… 201909… MIN     ATL     REG         1 MIN     home    ATL    
#>  8     185 2019_0… 201909… MIN     ATL     REG         1 MIN     home    ATL    
#>  9     214 2019_0… 201909… MIN     ATL     REG         1 MIN     home    ATL    
#> 10     239 2019_0… 201909… MIN     ATL     REG         1 MIN     home    ATL    
#> # … with 96,538 more rows, 362 more variables: side_of_field <chr>,
#> #   yardline_100 <dbl>, game_date <chr>, quarter_seconds_remaining <dbl>,
#> #   half_seconds_remaining <dbl>, game_seconds_remaining <dbl>,
#> #   game_half <chr>, quarter_end <dbl>, drive <dbl>, sp <dbl>, qtr <dbl>,
#> #   down <dbl>, goal_to_go <dbl>, time <chr>, yrdln <chr>, ydstogo <dbl>,
#> #   ydsnet <dbl>, desc <chr>, play_type <chr>, yards_gained <dbl>,
#> #   shotgun <dbl>, no_huddle <dbl>, qb_dropback <dbl>, qb_kneel <dbl>, …
#> # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
# }