Learn R Programming

StatsBombR (version 0.1.0)

getgamestate: This function returns additional variables for the game state, score and opposing score. It also returns a dataframe of the time each team spent winning.

Description

For use with the StatsBomb Data API credentials. After StatsBomb data is read in from the API, JSON file, this function will pull define the game state at the time of each event. It is often important for analysis to see how much time each team spends in each state. Therefore, we return a dataframe of the time each team is winning within each game as well.

Usage

get.gamestate(dataframe)

Arguments

dataframe

A dataframe with all events from a match.

Value

list

List of two data frames. The first element of the list is the original dataframe with new variables created defining the game state and current score for each team, and the second element of the list is a data frame of the time each team has spent winning, losing and drawing.

Examples

Run this code
# NOT RUN {
  ##Returns a list
  temp <- get.gamestate(AllEvents)
  AllEvents <- temp[1][[1]]
  GameStates <- temp[2][[1]]
# }

Run the code above in your browser using DataLab