R/team_summary.r

Defines functions get_team_stats

get_team_stats <- function(rawdata) {
  #DESCRIPTION - Modify raw_data to get team summary data frame

  enhanced_pbp <-
  #Create Data for Team Summary Graph
  team_stats <-
    rawdata %>%
    dplyr::filter(!is.na(event_team)) %>%
    dplyr::group_by(event_team) %>%
    dplyr::summarise(Goals = sum(event_type == "GOAL"),
                     Hits = sum(event_type == "HIT"),
                     Blocks = sum(event_type == "BLOCK"),
                     Corsi = sum(event_type %in% names(corsi_events)),
                     Shots = sum(event_type %in% c("SHOT","GOAL")),
                     Faceoffs = sum(event_type == "FAC")) %>%
    tidyr::gather(Event, Value, -event_team)

}
EFastner/icescrapR documentation built on Jan. 15, 2022, 1:11 p.m.