Skip to contents

build_nflfastR_pbp is a convenient wrapper around 6 nflfastR functions:

Please see either the documentation of each function or the nflfastR Field Descriptions website to learn about the output.

Usage

build_nflfastR_pbp(
  game_ids,
  dir = getOption("nflfastR.raw_directory", default = NULL),
  ...,
  decode = TRUE,
  rules = TRUE
)

Arguments

game_ids

Vector of character ids or a data frame including the variable game_id (see details for further information).

dir

Path to local directory (defaults to option "nflfastR.raw_directory") where nflfastR searches for raw game play-by-play data. See save_raw_pbp() for additional information.

...

Additional arguments passed to the scraping functions (for internal use)

decode

If TRUE, the function decode_player_ids() will be executed.

rules

If FALSE, printing of the header and footer in the console output will be suppressed.

Value

An nflfastR play-by-play data frame like it can be loaded from https://github.com/nflverse/nflverse-data.

Details

To load valid game_ids please use the package function fast_scraper_schedules().

See also

For information on parallel processing and progress updates please see nflfastR.

Examples

# \donttest{
# Build nflfastR pbp for the 2018 and 2019 Super Bowls
try({# to avoid CRAN test problems
build_nflfastR_pbp(c("2018_21_NE_LA", "2019_21_SF_KC"))
})
#> ── Build nflfastR Play-by-Play Data ───────────── nflfastR version 5.2.0.9004 ──
#> • 16:35:21 | Start download of 2 games...
#>  It is recommended to use parallel processing when trying to load multiple games.Please consider running `future::plan("multisession")`! Will go on sequentially...
#>  16:35:24 | Download finished. Adding variables...
#>  16:35:24 | added game variables
#>  16:35:24 | added nflscrapR variables
#>  16:35:25 | added ep variables
#>  16:35:25 | added air_yac_ep variables
#>  16:35:25 | added wp variables
#>  16:35:25 | added air_yac_wp variables
#>  16:35:25 | added cp and cpoe
#>  16:35:25 | added fixed drive variables
#>  16:35:26 | added series variables
#> • 16:35:26 | Cleaning up play-by-play...
#>  16:35:26 | Cleaning completed
#>  16:35:26 | added qb_epa
#> • 16:35:26 | Computing xyac...
#>  16:35:28 | added xyac variables
#> • 16:35:28 | Computing xpass...
#>  16:35:28 | added xpass and pass_oe
#> • 16:35:28 | Decode player ids...
#>  16:35:29 | Decoding of player ids completed
#> ── DONE ────────────────────────────────────────────────────────────────────────
#> ── nflverse play by play ───────────────────────────────────────────────────────
#>  Data updated: 2026-02-13 16:35:29 UTC
#> # A tibble: 349 × 372
#>    play_id game_id     old_game_id home_team away_team season_type  week posteam
#>      <dbl> <chr>       <chr>       <chr>     <chr>     <chr>       <int> <chr>  
#>  1       1 2018_21_NE… 2019020300  LA        NE        POST           21 NA     
#>  2      38 2018_21_NE… 2019020300  LA        NE        POST           21 NE     
#>  3      67 2018_21_NE… 2019020300  LA        NE        POST           21 NE     
#>  4      89 2018_21_NE… 2019020300  LA        NE        POST           21 NE     
#>  5     111 2018_21_NE… 2019020300  LA        NE        POST           21 NE     
#>  6     133 2018_21_NE… 2019020300  LA        NE        POST           21 NE     
#>  7     155 2018_21_NE… 2019020300  LA        NE        POST           21 NE     
#>  8     182 2018_21_NE… 2019020300  LA        NE        POST           21 LA     
#>  9     204 2018_21_NE… 2019020300  LA        NE        POST           21 LA     
#> 10     226 2018_21_NE… 2019020300  LA        NE        POST           21 LA     
#> # ℹ 339 more rows
#> # ℹ 364 more variables: posteam_type <chr>, defteam <chr>, 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>, …

# It is also possible to directly use the
# output of `load_schedules` as input
try({# to avoid CRAN test problems
nflreadr::load_schedules(2025) |>
  dplyr::slice_tail(n = 3) |>
  build_nflfastR_pbp()
})
#> ── Build nflfastR Play-by-Play Data ───────────── nflfastR version 5.2.0.9004 ──
#> • 16:35:29 | Start download of 3 games...
#>  It is recommended to use parallel processing when trying to load multiple games.Please consider running `future::plan("multisession")`! Will go on sequentially...
#>  16:35:32 | Download finished. Adding variables...
#>  16:35:32 | added game variables
#>  16:35:32 | added nflscrapR variables
#>  16:35:32 | added ep variables
#>  16:35:32 | added air_yac_ep variables
#>  16:35:33 | added wp variables
#>  16:35:33 | added air_yac_wp variables
#>  16:35:33 | added cp and cpoe
#>  16:35:33 | added fixed drive variables
#>  16:35:33 | added series variables
#> • 16:35:33 | Cleaning up play-by-play...
#>  16:35:33 | Cleaning completed
#>  16:35:33 | added qb_epa
#> • 16:35:33 | Computing xyac...
#>  16:35:34 | added xyac variables
#> • 16:35:34 | Computing xpass...
#>  16:35:34 | added xpass and pass_oe
#> • 16:35:34 | Decode player ids...
#>  16:35:34 | Decoding of player ids completed
#> ── DONE ────────────────────────────────────────────────────────────────────────
#> ── nflverse play by play ───────────────────────────────────────────────────────
#>  Data updated: 2026-02-13 16:35:34 UTC
#> # A tibble: 533 × 372
#>    play_id game_id     old_game_id home_team away_team season_type  week posteam
#>      <dbl> <chr>       <chr>       <chr>     <chr>     <chr>       <int> <chr>  
#>  1       1 2025_21_LA… 2026012501  SEA       LA        POST           21 NA     
#>  2      39 2025_21_LA… 2026012501  SEA       LA        POST           21 LA     
#>  3      62 2025_21_LA… 2026012501  SEA       LA        POST           21 LA     
#>  4      84 2025_21_LA… 2026012501  SEA       LA        POST           21 LA     
#>  5     109 2025_21_LA… 2026012501  SEA       LA        POST           21 LA     
#>  6     132 2025_21_LA… 2026012501  SEA       LA        POST           21 LA     
#>  7     152 2025_21_LA… 2026012501  SEA       LA        POST           21 SEA    
#>  8     174 2025_21_LA… 2026012501  SEA       LA        POST           21 SEA    
#>  9     197 2025_21_LA… 2026012501  SEA       LA        POST           21 SEA    
#> 10     222 2025_21_LA… 2026012501  SEA       LA        POST           21 SEA    
#> # ℹ 523 more rows
#> # ℹ 364 more variables: posteam_type <chr>, defteam <chr>, 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>, …

# }