nba_travel: NBA Travel & Schedule related Metrics

View source: R/NBA_travel.R

nba_travelR Documentation

NBA Travel & Schedule related Metrics

Description

Returns a dataframe with computed travel and schedule metrics for NBA teams. It requires the game_logs() function from on the nbastatR package written by Bresler, A (2020) <https://github.com/abresler/nbastatR> to query season schedule information that is needed to calculate travel metrics.

Usage

nba_travel(
  start_season = 2018,
  end_season = 2020,
  team = NULL,
  return_home = 20,
  phase = c("RS", "PO"),
  flight_speed = 550
)

Arguments

start_season

Numeric. The year of the first season users wish to explore (i.e. 2018)

end_season

Numeric. The year of the final season users wisth to explore (i.e. 2020)

team

Character String. The name of the team to be explored. If empty it defaults to all teams within the selected seasons.

return_home

Numeric. Users can set the number of days after which the team will return home between consecutive road games. It defaults to 20 if not indicated.

phase

Character String. The phase of the season users wish to download. RS for Regular Season and PO for Playoffs. It defauls to both if not indicated.

flight_speed

Numeric. Average cruising speed (in mph) for commercial flights. Used to adjust flight time estimation.

Value

A data frame with the following columns:

Season

A chracter string. The season(s) downloaded.

Month

A character String. The month of the season.

Week

Numeric. The week of the year.

Date

Date object. The date of the game.

Team

A character String. The name of the team.

Opponent

A character String. The name of the opponent.

Location

A character string. Location of the game. (Home or Away)

'W/L'

A character string. Outcome of the game. (W or L)

City

A character String. The name of the city in which the game is played.

Distance

Numeric. Estimated distance travelled (in miles) prior to a game.

Route

A character String. The route travelled for each game. If no travel involved it defaults to "No Travel".

Rest

Numeric. The number of days between games. It defaults to 15 for the first game for each team. If the team is making a "return_home" trip it will default to NA.

TZ

A character string. The time zone where the game is played.

'Shift (hrs)'

Numeric. The time zoen change in hours.

'Flight Time'

A character string. Aproximate duration of the flight for a given trip.

'Direction (E/W)'

A character string. Travel direction for trips involving zone changes.

'Return Home'

A character string. If yes, team is making a "return_home" trip.

Latitude

Numeric. Latitude of the origin location.

Longitude

Numeric. Longitude of the origin location.

d.Latitude

Numeric. Latitude of the destication location.

d.Longitude

Numeric. Longitude of the destination location.

Examples

nba_travel(start_season = 2017,
           end_season = 2020,
           team = c("Los Angeles Lakers", "Boston Celtics"),
           return_home = 3,
           phase = "RS",
           flight_speed = 550)


josedv82/airball documentation built on June 27, 2023, 2:51 p.m.