Skip to content

Commit

Permalink
Convert team abbr "PHO" to "ARI"
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Oct 3, 2024
1 parent 8e4e0a0 commit d08fdd6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nflreadr
Title: Download 'nflverse' Data
Version: 1.4.1.03
Version: 1.4.1.04
Authors@R: c(
person("Tan", "Ho", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-8388-5155")),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
across all nflverse data. When printing to the console, nflreadr will convert timestamps to the user local timezone.
- Added several player name mappings (#249, #253, #255)
- Added a dictionary to describe what each shorthand roster status indicates (#232)
- `clean_team_abbrs()` now converts `"PHO"` to `"ARI"`. (#260)

---

Expand Down
3 changes: 2 additions & 1 deletion data-raw/build_teamplayer_mappings.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ teams <- csv_from_url("https://github.com/nflverse/nfldata/raw/master/data/teams
"SD","SDC",
"AFC", "AFC",
"NFC", "NFC",
"NFL", "NFL"
"NFL", "NFL",
"ARI", "PHO"
)
) %>%
dplyr::arrange(alternate)
Expand Down
Binary file modified data/team_abbr_mapping.rda
Binary file not shown.
Binary file modified data/team_abbr_mapping_norelocate.rda
Binary file not shown.
24 changes: 12 additions & 12 deletions tests/testthat/test-utils_name_cleaning.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ test_that("cleaning team abbreviations", {

expected_warning <- "Abbreviations not found in `nflreadr::team_abbr_mapping`: PIE"

x <- c("PIE","LAR","PIT","CRD", "OAK", "CLV")
x <- c("PIE","LAR","PIT","CRD", "OAK", "CLV", "PHO")
expect_warning(new_abbr <- clean_team_abbrs(x),regexp = expected_warning)
expect_warning(old_abbr <- clean_team_abbrs(x, current_location = FALSE), regexp = expected_warning)
expect_warning(new_abbr_drop <- clean_team_abbrs(x, keep_non_matches = FALSE),regexp = expected_warning)

expect_equal(new_abbr, c("PIE", "LA","PIT","ARI","LV","CLE"))
expect_equal(new_abbr_drop, c(NA, "LA","PIT","ARI","LV","CLE"))
expect_equal(old_abbr, c("PIE", "LA","PIT","ARI","OAK","CLE"))
expect_equal(new_abbr, c("PIE", "LA","PIT","ARI","LV","CLE", "ARI"))
expect_equal(new_abbr_drop, c(NA, "LA","PIT","ARI","LV","CLE", "ARI"))
expect_equal(old_abbr, c("PIE", "LA","PIT","ARI","OAK","CLE", "ARI"))
options(o)
})

Expand Down Expand Up @@ -51,16 +51,16 @@ test_that("all caps names with suffix are cleaned correctly", {
test_that("cleaning home and away columns",{

s <- data.frame(
game_id = c("2020_20_TB_GB", "2020_20_BUF_KC", "2020_21_KC_TB"),
game_type = c("CON", "CON", "SB"),
home_team = c("GB", "KC", "TB"),
game_id = c("2020_20_TB_GB", "2020_20_BUF_KC", "2020_21_KC_TB"),
game_type = c("CON", "CON", "SB"),
home_team = c("GB", "KC", "TB"),
home_score = c(26L, 38L, 31L),
team_id_home = c("001","002","003"),
away_team = c("TB", "BUF", "KC"),
away_score = c(31L, 24L, 9L),
team_id_home = c("001","002","003"),
away_team = c("TB", "BUF", "KC"),
away_score = c(31L, 24L, 9L),
team_id_away = c("003","004","002"),
location = c("Home", "Home", "Neutral"),
result = c(-5L, 14L, 22L),
location = c("Home", "Home", "Neutral"),
result = c(-5L, 14L, 22L),
spread_line = c(3, 3, -3)
)
c <- clean_homeaway(s, invert = c("result","spread_line"))
Expand Down

0 comments on commit d08fdd6

Please sign in to comment.