MyNixOS website logo
Description

Download 'nflverse' Data.

A minimal package for downloading data from 'GitHub' repositories of the 'nflverse' project.

nflreadr

CRANstatus Codecov testcoverage Devstatus Lifecycle:stable R buildstatus nflversediscord

nflreadr is a minimal package for downloading data from nflverse repositories. It includes caching, optional progress updates, and data dictionaries.

Please note that nflverse data repositories have been reorganized and pushed towards the nflverse-data repo, and v1.2.0+ is the minimum version that supports this change. We encourage all users to upgrade to this version immediately.

For Python access to nflverse data, please check out nfl-data-py - maintained by Cooper Adams.

Installation

Install the stable version from CRAN with:

install.packages("nflreadr")

Install the development version from GitHub with:

install.packages("nflreadr", repos = c("https://nflverse.r-universe.dev", getOption("repos")))

# or use remotes/devtools
# install.packages("remotes")
remotes::install_github("nflverse/nflreadr")

Usage

The main functions of nflreadr are prefixed with load_.

library(nflreadr)

load_pbp(2021)
#> ── nflverse play by play data ──────────────────────────────────────────────────
#> ℹ Data updated: 2022-09-27 04:35:02 PDT
#> # A tibble: 50,712 × 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 2021_01_AR… 2021091207  TEN       ARI       REG             1 <NA>   
#>  2      40 2021_01_AR… 2021091207  TEN       ARI       REG             1 TEN    
#>  3      55 2021_01_AR… 2021091207  TEN       ARI       REG             1 TEN    
#>  4      76 2021_01_AR… 2021091207  TEN       ARI       REG             1 TEN    
#>  5     100 2021_01_AR… 2021091207  TEN       ARI       REG             1 TEN    
#>  6     122 2021_01_AR… 2021091207  TEN       ARI       REG             1 TEN    
#>  7     152 2021_01_AR… 2021091207  TEN       ARI       REG             1 ARI    
#>  8     181 2021_01_AR… 2021091207  TEN       ARI       REG             1 ARI    
#>  9     218 2021_01_AR… 2021091207  TEN       ARI       REG             1 ARI    
#> 10     253 2021_01_AR… 2021091207  TEN       ARI       REG             1 ARI    
#> # ℹ 50,702 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>, …

load_player_stats(2021)
#> ── nflverse player stats: offense ──────────────────────────────────────────────
#> ℹ Data updated: 2023-02-28 01:26:47 PST
#> # A tibble: 5,698 × 52
#>    player_id  player_name player_display_name position position_group
#>    <chr>      <chr>       <chr>               <chr>    <chr>         
#>  1 00-0019596 T.Brady     Tom Brady           QB       QB            
#>  2 00-0019596 T.Brady     Tom Brady           QB       QB            
#>  3 00-0019596 T.Brady     Tom Brady           QB       QB            
#>  4 00-0019596 T.Brady     Tom Brady           QB       QB            
#>  5 00-0019596 T.Brady     Tom Brady           QB       QB            
#>  6 00-0019596 T.Brady     Tom Brady           QB       QB            
#>  7 00-0019596 T.Brady     Tom Brady           QB       QB            
#>  8 00-0019596 T.Brady     Tom Brady           QB       QB            
#>  9 00-0019596 T.Brady     Tom Brady           QB       QB            
#> 10 00-0019596 T.Brady     Tom Brady           QB       QB            
#> # ℹ 5,688 more rows
#> # ℹ 47 more variables: headshot_url <chr>, recent_team <chr>, season <int>,
#> #   week <int>, season_type <chr>, completions <int>, attempts <int>,
#> #   passing_yards <dbl>, passing_tds <int>, interceptions <dbl>, …

Data Sources

Data accessed by this package is stored on GitHub and can typically be found in one of the following repositories:

For a full list of functions, please see the reference page.

This data is maintained by the nflverse project team and is primarily automated via GitHub Actions. You can check the status and schedules page here: https://github.com/nflverse/nflverse-data

Configuration

The following options help configure default nflreadr behaviours.

options(nflreadr.verbose) 
# TRUE/FALSE to silence messages such as cache warnings
options(nflreadr.cache) 
# one of "memory", "filesystem", or "off"
options(nflreadr.prefer) 
# one of "qs", "rds", "parquet", or "csv"
options(nflreadr.download_path)
# defaults to current working directory - change to specify where `nflverse_download()` places data.

You can also configure nflreadr to display progress messages with the progressr package, e.g.

progressr::with_progress(load_rosters(seasons = 2010:2020))
 |========            |  40%

Getting help

The best places to get help on this package are:

Contributing

Many hands make light work! Here are some ways you can contribute to this project:

Terms of Use

The R code for this package is released as open source under the MIT License. NFL data accessed by this package belong to their respective owners, and are governed by their terms of use.

Metadata

Version

1.4.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows