Learn R Programming

BAwiR (version 1.3.4)

do_process_acb_pbp: 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)

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.

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.

Author

Guillermo Vinue

Examples

Run this code
if (FALSE) {
# 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)
}

Run the code above in your browser using DataLab