|
|
@@ -6,7 +6,7 @@ library(tidyverse)
|
|
|
# with the filename as an ID column
|
|
|
datafiles <- list.files("data", pattern="*_pbp.csv", full.names = FALSE)
|
|
|
|
|
|
-seasons <- purrr:map_df(datafiles,
|
|
|
+seasons <- purrr::map_df(datafiles,
|
|
|
~read_csv(paste0("data/", .x)),
|
|
|
.id = "filename")
|
|
|
|
|
|
@@ -14,7 +14,9 @@ seasons <- purrr:map_df(datafiles,
|
|
|
# also ensure that SCOREMARGIN is a number and create an integer gameID
|
|
|
season_subset <- seasons %>%
|
|
|
dplyr::select(GAME_ID, EVENTNUM, HOMEDESCRIPTION, VISITORDESCRIPTION,
|
|
|
- SCORE, SCOREMARGIN, PCTIMESTRING, PERIOD) %>%
|
|
|
+ SCORE, SCOREMARGIN, PCTIMESTRING, PERIOD,
|
|
|
+ PLAYER1_TEAM_ABBREVIATION, PLAYER1_TEAM_CITY,
|
|
|
+ PLAYER1_TEAM_NICKNAME) %>%
|
|
|
mutate(SCOREMARGIN = as.numeric(SCOREMARGIN)) %>%
|
|
|
mutate(GAME_ID_INT = as.integer(GAME_ID))
|
|
|
|