do_process_acb_pbp {BAwiR} | R Documentation |
Processing of the ACB website play-by-play data
Description
This function disentangles the play-by-play data coming from the ACB website and creates a common data structure in R.
Usage
do_process_acb_pbp(game_elem, day, game_code, period, acb_shields, verbose)
Arguments
game_elem |
Character with the tangled play-by-play data. |
day |
Day of the game. |
game_code |
Game code. |
period |
Period of the game. |
acb_shields |
Data frame with the links to the shields of the ACB teams. |
verbose |
Logical to display processing information. |
Value
Data frame with eight columns:
period: Period of the game.
time_point: Time point when the basketball action happens.
player: Player who performs the action.
action: Basketball action.
local_score: Local score at that time point.
visitor_score: Visitor score at that time point.
day: Day of the game.
game_code: Game code.
Note
1. Actions are given in Spanish. A bilingual basketball vocabulary (Spanish/English) is provided in https://www.uv.es/vivigui/docs/basketball_dictionary.xlsx.
2. The game_code column allows us to detect the source website, for example, https://jv.acb.com/es/103389/jugadas.
Author(s)
Guillermo Vinue
Examples
## Not run:
# Load packages required:
library(RSelenium)
# Provide the day and game code:
day <- "24"
game_code <- "103170"
# Open an Internet server:
rD <- rsDriver(browser = "firefox", chromever = NULL)
# Follow this procedure on the server:
# 1. Copy and paste the game link https://jv.acb.com/es/103170/jugadas
# 2. Click on each period, starting with 1C.
# 3. Scroll down to the first row of data.
# 4. Go back to R and run the following code:
# Set the remote driver:
remDr <- rD$client
# Get the play-by-play data:
game_elem <- remDr$getPageSource()[[1]]
# Close the client and the server:
remDr$close()
rD$server$stop()
period <- "1C"
data_game <- do_process_acb_pbp(game_elem, day, game_code,
period, acb_shields, FALSE)
## End(Not run)