clean_team_abbrs: Standardize NFL Team Abbreviations

Description Usage Arguments Value Examples

View source: R/name_cleaning.R

Description

This function standardizes NFL team abbreviations to nflverse defaults. This helps for joins and plotting, especially with the new nflplotR package!

Usage

1
clean_team_abbrs(abbr, current_location = TRUE, keep_non_matches = TRUE)

Arguments

abbr

a character vector of abbreviations

current_location

If TRUE (the default), the abbreviation of the most recent team location will be used.

keep_non_matches

If TRUE (the default) an element of abbr that can't be matched to any of the internal mapping vectors will be kept as is. Otherwise it will be replaced with NA.

Value

A character vector with the length of abbr and cleaned team abbreviations if they are included in team_abbr_mapping or team_abbr_mapping_norelocate (depending on the value of current_location). Non matches may be replaced with NA (depending on the value of keep_non_matches).

Examples

1
2
3
4
5
6
x <- c("PIE", "LAR", "PIT", "CRD", "OAK", "SL")
# use current location and keep non matches
clean_team_abbrs(x)

# keep old location and replace non matches
clean_team_abbrs(x, current_location = FALSE, keep_non_matches = FALSE)

nflreadr documentation built on Oct. 6, 2021, 1:10 a.m.