nflfastR – NFL Play-by-Play (1999 – 2023)

nflfastR is a set of functions to efficiently scrape NFL play-by-play data. nflfastR expands upon the features of nflscrapR:

The package contains NFL play-by-play data back to 1999
As suggested by the package name, it obtains games much faster
Includes completion probability (cp), completion percentage over expected (cpoe), and expected yards after the catch (xyac_epa and xyac_mean_yardage) in play-by-play going back to 2006
Includes drive information, including drive starting position and drive result
Includes series information, including series number and series success
Hosts a release of play-by-play data going back to 1999 for very quick access
Features models for Expected Points, Win Probability, Completion Probability, and Yards After the Catch (see section below)
Includes a function update_db() that creates and updates a database

Use case
4ᵗʰ-down Decision-Maker

Example observationsquarter, game_clock, half_seconds_remaining, score_differential down (=4), ydstogo, yardline_100 (distance to end-zone)  
posteam vs defteam indicators, home_field flag  
weather, roof type, surface  
timeouts_remaining_off / _def  
pre-snap win probability (wp)  
season & week (optional for non-stationarity)
Example actionsPunt  
Field-goal attempt  
Go-for-it
Example rewardImmediate: win probability added wp_post – wp (already computed in the file)
Alternative shaping: expected points added (epa) or binary win at game end