Learn R Programming

nflfastR (version 3.2.0)

decode_player_ids: Decode the player IDs in nflfastR play-by-ply data

Description

Takes all columns ending with 'player_id' as well as the variables 'passer_id', 'rusher_id', 'receiver_id' and 'id' of an nflfastR play-by-play data set and decodes the player IDs to the commonly known GSIS ID format 00-00xxxxx.

The function uses by default the high efficient decode_ids of the package gsisdecoder. In the unlikely event that there is a problem with this function, an nflfastR internal decoder can be used with the option fast = FALSE. In that case the function requires the package furrr if the data frame pbp has more than 4500 rows.

Usage

decode_player_ids(pbp, ..., fast = TRUE)

Arguments

pbp

is a Data frame of play-by-play data scraped using fast_scraper.

...

Additional arguments passed to a message function (for internal use).

fast

If TRUE the IDs will be decoded with the high efficient function decode_ids. If FALSE an nflfastR internal function will be used for decoding (it is generally not recommended to do this, unless there is a problem with decode_ids which can take several days to fix on CRAN.)

Value

The input data frame of the parameter pbp with decoded player IDs.

Examples

Run this code
# NOT RUN {
# Decode data frame consisting of some names and ids
decode_player_ids(data.frame(
  name = c("P.Mahomes", "B.Baldwin", "P.Mahomes", "S.Carl", "J.Jones"),
  id = c(
  "32013030-2d30-3033-3338-3733fa30c4fa",
  NA_character_,
  "00-0033873",
  NA_character_,
  "32013030-2d30-3032-3739-3434d4d3846d"
  )
))
# }

Run the code above in your browser using DataLab