nflverse / nflverse-rosters

builds roster data for nflverse/nflverse-data
Other
20 stars 3 forks source link

pff ID code #62

Open tanho63 opened 1 year ago

tanho63 commented 1 year ago
library(dplyr)
library(purrr)
library(jsonlite)

pff_cfb <- expand.grid(
  season = 2016:2022,
  position = c('QB', 'WR', 'HB', 'FB', 'TE', 'C', 'G', 'T', 'CB', 'S', 'LB', 'DI', 'ED', 'K', 'P')
)  |> 
  dplyr::mutate(
    url = paste0('https://www.pff.com/api/nfl/grades?league=ncaa&position=',
                 position, "&season=", season),
    season = NULL,
    position = NULL
  )  |> 
  dplyr::pull()  |> 
  list()  |> 
  purrr::pmap_dfr(function(x) {
    jsonlite::fromJSON(x)  |> 
      purrr::pluck("players")
  })

pff_nfl <- expand.grid(
  season = 2018:2022,
  position = c('QB', 'WR', 'HB', 'FB', 'TE', 'C', 'G', 'T', 'CB', 'S', 'LB', 'DI', 'ED', 'K', 'P')
)  |> 
  dplyr::mutate(
    url = paste0('https://www.pff.com/api/nfl/grades?league=nfl&position=',
                 position, "&season=", season),
    season = NULL,
    position = NULL
  )  |> 
  dplyr::pull()  |> 
  list()  |> 
  purrr::pmap_dfr(function(x) {
    jsonlite::fromJSON(x)  |> 
      purrr::pluck("players")
  }