Install via:

library(tidyverse) # always a good idea to do this too

Using puntr with NFL data

Completed seasons

For speed, we’ve already scraped (using nflfastR) and saved punting data for the 1999-2020 seasons. The easiest thing to do is download the puntr-data repo here, and then point puntr::import_punts() to your local copy of the data. You can also download the data directly each time; this takes around 15 minutes.
Import, clean, and calculate as follows:

#punts_raw <- import_punts(1999:2020, local=TRUE, path=your_local_path) # recommended
punts_raw <- import_punts(2018:2020) # This takes ~15 minutes
punts_cleaned <- trust_the_process(punts_raw) # clean
punts <- calculate_all(punts_cleaned) # calculate custom Puntalytics metrics 
## Calculated RERUN: 0.39 sec elapsed
## Calculated SHARP: 4.824 sec elapsed
## Calculated pEPA: 1.03 sec elapsed

You now have a dataframe punts where each row is a punt, and each column is a stat relevant to punting (including our custom metrics).

Note about minimum dataframe size

puntr calculates stats using 3-year rolling averages, to avoid any artifacts of anomalous seasons. For this reason, puntr::calculate_all() requires a dataframe containing at least 3 seasons and 1000 punts. Note in the above example that three seasons are used. Note in the below example that three seasons are used for the calculation, after which all but the most recent seasons are filtered out.

In-progress seasons

The kind folks at nflfastR have set up a convenient SQL-y way to scrape data for in-progress seasons. Rather than redo all of that work, we’ll just share here the code we use for this purpose:


connection <- dbConnect(SQLite(), "./pbp_db")
pbp <- tbl(connection, "nflfastR_pbp")

punts <- pbp %>% filter(punt_attempt==1) %>%
  filter(season %in% 2019:2021)
  collect() %>%
  trust_the_process() %>%
  calculate_all() %>%
  filter(season == 2021)


Comparing punters

To compare punters, continue with

mini <- create_mini(punts)

to get a dataframe where each row is a punter, and each column is an average stat for that punter. There are many columns in this dataframe, but here’s a few of the most interesting:

mini <- mini %>% arrange(desc(Punt_eaepaae_avg)) %>% select(punter_player_name, Gross, Net, SHARP_RERUN, Punt_eaepaae_avg)

To compare punter seasons, instead use

miniY <- create_miniY(punts)
which gives every unique punter season a row.

To compare punter games, instead use

miniG <- create_miniG(punts)
which gives every unique punter game a row.

These dataframes - punts, mini, miniY and miniG - should serve as a good starting point for any custom analysis you’d like to do, be that using built-in puntr metrics, or your own. If a punter or punter-season you’re looking for is missing, try playing around with the threshold = parameter.

Using puntr with college data

NOTE: puntr was successfully migrated from cfbscrapR to cfbfastR in version 1.2.2

puntr can also handle punting data for college football, piggybacking off of the scraping abilities of the cfbfastR package. You need at least 3 seasons worth of data to run calculate_all(). Import and clean as follows:

college_punts <- import_college_punts(2019:2021) %>% # import (calls cfbfastR behind the scenes)
 college_to_pro() %>% # rename columns to those used by nflfastR
 calculate_all() # calculate as with NFL data

Now we can use the same create_miniY as above to compare college punter seasons (create_mini and create_miniG would also work here, of course.)

miniY_college <- create_miniY(college_punts)