-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #29
- Loading branch information
Showing
7 changed files
with
109 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# position abbrev slot pos | ||
# Quarterback QB 0 1 | ||
# Team Quarterback TQB 1 | ||
# Running Back RB 2 2 | ||
# Running Back/Wide Receiver RB/WR 3 | ||
# Wide Receiver WR 4 3 | ||
# Wide Receiver/Tight End WR/TE 5 | ||
# Tight End TE 6 4 | ||
# Flex FLEX 23 | ||
# Offensive Player Utility OP 7 | ||
# Defensive Tackle DT 8 9 | ||
# Defensive End DE 9 10 | ||
# Linebacker LB 10 11 | ||
# Defensive Line DL 11 | ||
# Cornerback CB 12 12 | ||
# Safety S 13 13 | ||
# Defensive Back DB 14 | ||
# Defensive Player Utility DP 15 | ||
# Team Defense/Special Teams D/ST 16 16 | ||
# Place Kicker K 17 5 | ||
# Punter P 18 7 | ||
# Head Coach HC 19 14 | ||
# Bench BE 20 | ||
# Injured Reserve IR 21 | ||
|
||
slot_abbrev <- function(slot) { | ||
stopifnot(is.numeric(slot)) | ||
factor(slot, levels = pos_ids$slot, labels = pos_ids$abbrev) | ||
} | ||
|
||
slot_unabbrev <- function(abbrev) { | ||
stopifnot(is.character(abbrev)) | ||
pos_ids$slot[match(abbrev, pos_ids$abbrev)] | ||
} | ||
|
||
pos_abbrev <- function(pos) { | ||
pos_abbrev <- pos_ids$abbrev[!is.na(pos_ids$position)] | ||
stopifnot(is.numeric(pos)) | ||
factor(pos, levels = pos_ids$position, labels = pos_abbrev) | ||
} | ||
|
||
pos_unabbrev <- function(abbrev) { | ||
stopifnot(is.character(abbrev)) | ||
pos_ids$position[match(abbrev, pos_ids$abbrev)] | ||
} | ||
|
||
pro_abbrev <- function(proTeamId) { | ||
fflr::nfl_teams$abbrev[match(proTeamId, fflr::nfl_teams$proTeamId)] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
## code to prepare `position_ids` dataset goes here | ||
|
||
# Quarterback QB 0 1 | ||
# Team Quarterback TQB 1 | ||
# Running Back RB 2 2 | ||
# Running Back/Wide Receiver RB/WR 3 | ||
# Wide Receiver WR 4 3 | ||
# Wide Receiver/Tight End WR/TE 5 | ||
# Tight End TE 6 4 | ||
# Flex FLEX 23 | ||
# Offensive Player Utility OP 7 | ||
# Defensive Tackle DT 8 9 | ||
# Defensive End DE 9 10 | ||
# Linebacker LB 10 11 | ||
# Defensive Line DL 11 | ||
# Cornerback CB 12 12 | ||
# Safety S 13 13 | ||
# Defensive Back DB 14 | ||
# Defensive Player Utility DP 15 | ||
# Team Defense/Special Teams D/ST 16 16 | ||
# Place Kicker K 17 5 | ||
# Punter P 18 7 | ||
# Head Coach HC 19 14 | ||
# Bench BE 20 | ||
# Injured Reserve IR 21 | ||
|
||
pos_ids <- tibble::tribble( | ||
~name, ~abbrev, ~slot, ~position, | ||
"Quarterback", "QB", 0, 1, | ||
"Team Quarterback", "TQB", 1, NA, | ||
"Running Back", "RB", 2, 2, | ||
"Running Back/Wide Receiver", "RB/WR", 3, NA, | ||
"Wide Receiver", "WR", 4, 3, | ||
"Wide Receiver/Tight End", "WR/TE", 5, NA, | ||
"Tight End", "TE", 6, 4, | ||
"Flex", "FLEX", 23, NA, | ||
"Offensive Player Utility", "OP", 7, NA, | ||
"Defensive Tackle", "DT", 8, 9, | ||
"Defensive End", "DE", 9, 10, | ||
"Linebacker", "LB", 10, 11, | ||
"Defensive Line", "DL", 11, NA, | ||
"Cornerback", "CB", 12, 12, | ||
"Safety", "S", 13, 13, | ||
"Defensive Back", "DB", 14, NA, | ||
"Defensive Player Utility", "DP", 15, NA, | ||
"Team Defense/Special Teams", "D/ST", 16, 16, | ||
"Place Kicker", "K", 17, 5, | ||
"Punter", "P", 18, 7, | ||
"Head Coach", "HC", 19, 14, | ||
"Bench", "BE", 20, NA , | ||
"Injured Reserve", "IR", 21, NA | ||
) | ||
|
||
pos_ids$slot <- as.integer(pos_ids$slot) | ||
pos_ids$position <- as.integer(pos_ids$position) | ||
|
||
usethis::use_data(pos_ids, internal = TRUE, overwrite = TRUE) |