### Install nbastatR Package Source: https://github.com/abresler/nbastatr/blob/master/docs/index.html Install the nbastatR package from GitHub using devtools. Ensure you have the devtools package installed. ```r devtools::install_github("abresler/nbastatR") ``` -------------------------------- ### Install nbastatR Package Source: https://github.com/abresler/nbastatr/blob/master/README.md Install the nbastatR package from GitHub using devtools. Ensure you have devtools installed. ```r devtools::install_github("abresler/nbastatr") ``` -------------------------------- ### Setup Parallel Computing with nbastatR Source: https://context7.com/abresler/nbastatr/llms.txt Enable parallel execution for iterative functions in nbastatR using the future package. Ensure you have the 'future' and 'furrr' packages installed. ```r library(nbastatR) library(future) # Use multiprocess (or multisession on Windows) plan(multisession) # Now all map-based fetches run in parallel game_logs(seasons = 2015:2020, result_types = c("player", "team")) ``` -------------------------------- ### Example usage of nbadraftnet_mock_drafts Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nbadraftnet_mock_drafts.html Example demonstrating how to call the `nbadraftnet_mock_drafts` function to retrieve mock draft data for the years 2012 through 2017, with NBA player data merged and a progress message enabled. ```R nbadraftnet_mock_drafts(years = 2012:2017, merge_nba_data = TRUE, nest_data = FALSE, return_message = TRUE) ``` -------------------------------- ### Get Specific NBA Award Winners Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/bref_awards.html Example of retrieving winners for a subset of awards, such as MVP, Rookie of the Year, and Defensive Player of the Year. ```R bref_awards(awards = c("Most Valuable Player", "Rookie of the Year", "Defensive Player of the Year")) ``` -------------------------------- ### Run nbastatr Development Commands Source: https://github.com/abresler/nbastatr/blob/master/CLAUDE.md Common development tasks for the nbastatr package using devtools and testthat. Ensure you have the necessary packages installed. ```r # Generate documentation and NAMESPACE from Roxygen2 comments devtools::document() ``` ```r # Build the package devtools::build() ``` ```r # Run R CMD check devtools::check() ``` ```r # Install locally devtools::install() ``` ```r # Run all tests devtools::test() ``` ```r # Run a single test file testthat::test_file("tests/testthat/test-nbastatr.R") ``` -------------------------------- ### Example: Fetching Agents by Name Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/agents_players.html Demonstrates how to call the agents_players function with a specific agent name. Ensure the 'c' function from the base R package is available. ```r agents_players(agents = c("Jeff Schwartz")) ``` -------------------------------- ### Get NBA Franchise History Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nba_franchise_history.html Acquires history for all NBA franchises. Use with default arguments to get all active teams and a success message. ```R nba_franchise_history() ``` -------------------------------- ### Enable Parallel Computing with nbastatR Source: https://github.com/abresler/nbastatr/blob/master/README.md Utilize parallel computing for iterative functions in nbastatR by setting a plan with the future package. This example uses multiprocess. ```r library(nbastatR) library(future) plan(multiprocess) ``` ```r game_logs(seasons = 2010:2019) ``` -------------------------------- ### Get FanDuel Summary for Games Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/fanduel_summary.html Call the fanduel_summary function with a vector of game IDs to retrieve their FanDuel summary. Set nest_data to FALSE and return_message to TRUE to get the tibble and a confirmation message. ```R fanduel_summary(game_ids = c(21700002, 21700003), nest_data = F, return_message = T) ``` -------------------------------- ### Implement Memoization in R Source: https://github.com/abresler/nbastatr/blob/master/CLAUDE.md Example of using the `memoise` package to cache function responses, reducing redundant computations. This is a common pattern in the nbastatr package for API calls. ```r function_name <- memoise::memoise(function(...) { ... }) ``` -------------------------------- ### Get Play-by-Play Data with nbastatR Source: https://context7.com/abresler/nbastatr/llms.txt Retrieve play-by-play data for specified game IDs. The function returns a message indicating completion. ```r library(nbastatR) # Get PBP for a single game pbp <- play_by_play(game_ids = 21700001, return_message = TRUE) pbp %>% select(timeQuarter, numberPeriod, descriptionPlayHome, descriptionPlayVisitor, scoreHome, scoreAway) %>% head(10) ``` -------------------------------- ### Get NBA Player Table Data Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/players_tables.html Fetches player data for specified players, tables, modes, and measures. Assigns data to the environment if TRUE. ```R players_tables( players = c("Caris LeVert", "Joe Harris"), tables = c("year over year", "passes", "game splits"), modes = c("PerGame", "Totals"), measures = c("Base", "Advanced"), assign_to_environment = TRUE ) ``` -------------------------------- ### Get Current Standings Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/current_standings.html Acquires the current season's standings. Returns a tibble. ```r current_standings() ``` -------------------------------- ### Get All Active Teams' Annual Stats Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/teams_annual_stats.html Retrieves total stats for all active NBA teams for the regular season. Ensure the 'totals' mode is specified. ```R teams_annual_stats(all_active_teams = T, modes = c("Totals"), return_message = TRUE, nest_data =F) ``` -------------------------------- ### Get Player Bios by Name Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/players_bios.html Retrieves player biographies by providing a vector of player names. This function is intended for use with the 2013-14 season. ```R players_bios(players = c("Carmelo Anthony", "Joe Johnson")) ``` -------------------------------- ### Get Team Season Shot Charts Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/teams_shots.html Retrieves shot charts for a specific team and season. Ensure the team name and season year are correctly specified. ```R teams_shots(teams = "Brooklyn Nets", seasons = 2018) ``` -------------------------------- ### Get Active Coaching Staffs Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/coaching_staffs.html Retrieves active coaching staff information for all NBA teams. Returns a tibble containing the data. ```APIDOC ## coaching_staffs() ### Description Gets active coaching staff information for all NBA teams. ### Method Function Call ### Endpoint N/A (R function) ### Parameters None ### Request Example ```R coaching_staffs() ``` ### Response #### Success Response - A `tibble` containing active coaching staff information. #### Response Example ```R # Example tibble structure (actual data will vary) # A tibble: 30 x 10 TeamID TeamName CoachID CoachName StartDate EndDate Status Notes Source 1 ATL Atlanta Quin Snyder 2021-07-15 2023-05-01 Head Coach NA bref 2 BOS Boston Joe Mazulla 2022-11-01 2023-05-01 Head Coach NA bref ... ... ... ... ... ... ... ... ... ``` ``` -------------------------------- ### Get Hoopshype Salaries Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/hoopshype_salaries.html Retrieves all team salaries from Hoopshype. Assumes default values for options and does not nest data. ```R library(dplyr) df_salaries <- hoopshype_salaries(all_teams = TRUE, nest_data = F, return_message = T) ``` -------------------------------- ### Get Player Season Stats from Basketball-Reference Source: https://context7.com/abresler/nbastatr/llms.txt Fetches player season statistics from Basketball-Reference, joining advanced, per-game, and totals tables. Optionally includes All-NBA award flags. Results can be assigned to the environment. ```r library(nbastatR) # Get advanced + totals stats for 2016–2018 seasons bref_players_stats( seasons = 2016:2018, tables = c("advanced", "totals"), include_all_nba = TRUE, only_totals = TRUE, assign_to_environment = TRUE, return_message = TRUE ) # Result assigned to dataBREFPlayerAdvanced, dataBREFPlayerTotals, # and joined wide frame in .GlobalEnv dataBREFPlayerTotals %>% filter(yearSeason == 2018) %>% arrange(desc(ptsTotal)) %>% select(namePlayer, slugSeason, slugTeamsBREF, ptsTotal, minutesTotals, isAllNBA) %>% head(10) ``` -------------------------------- ### Get NBA Seasons Schedule Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/seasons_schedule.html Retrieves the NBA season schedule for multiple seasons. Specify the desired seasons as a vector. ```R seasons_schedule(seasons = c(2012, 2018)) ``` -------------------------------- ### Get All NBA Team Details Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/teams_details.html Retrieves details for all NBA teams and assigns them to the environment. Set assign_to_environment to TRUE to make the data available as a data frame in your R session. ```R teams_details(all_teams = TRUE, assign_to_environment = TRUE) ``` -------------------------------- ### Get NBA Teams Rosters for Specified Seasons Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/teams_rosters.html Use this function to retrieve NBA team rosters for a given range of seasons. Set `return_message = TRUE` to see a progress message during execution. ```R teams_rosters(seasons = 2010:2018, nest_data = FALSE, return_message = TRUE) ``` -------------------------------- ### Get Team Season Stats from Basketball-Reference Source: https://context7.com/abresler/nbastatr/llms.txt Retrieves comprehensive team statistics from Basketball-Reference for specified seasons. Includes per-game, totals, per-possession, shooting, miscellaneous, and standings data. Data can be joined and widened. ```r library(nbastatR) # Fetch team stats for multiple seasons bref_teams_stats( seasons = 2017:2019, return_message = TRUE, assign_to_environment = TRUE, join_data = TRUE, widen_data = TRUE ) # Widened joined team data in .GlobalEnv as dataBREFTeamJoined dataBREFTeamJoined %>% filter(yearSeason == 2019) %>% arrange(desc(nrtgTeam)) %>% select(nameTeam, winsTeam, lossesTeam, paceTeam, ortgTeam, drtgTeam, nrtgTeam) %>% head(10) ``` -------------------------------- ### Get Active Coaching Staffs - R Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/coaching_staffs.html Call the `coaching_staffs` function to retrieve active coaching staff information for all NBA teams. This function returns a tibble. ```r coaching_staffs() ``` -------------------------------- ### Get NBA Team Dictionary Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nba_teams.html Returns a tibble containing NBA team information. The `join_blg` argument can be set to TRUE to include BLG team features data. ```R nba_teams() ``` -------------------------------- ### Get HoopsHype Team Salary Summary Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/hoops_hype_salary_summary.html Call the function to retrieve team salary summaries. The `spread_data` argument can be set to TRUE to include spread data if available. ```R hoops_hype_salary_summary(spread_data = TRUE) ``` -------------------------------- ### Get Franchise Leaders by Team and Mode Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/franchise_leaders.html Use this function to retrieve franchise leader data for a specific team and mode. Ensure the 'c()' function is available for vector creation. ```R franchise_leaders(teams = "Brooklyn Nets", modes = c("Totals")) ``` -------------------------------- ### Get All-Star Game Information Source: https://context7.com/abresler/nbastatr/llms.txt Returns scores, dates, venues, and MVP information for NBA (and optionally ABA) All-Star Games. Can be used to find frequent MVPs or game details. ```r library(nbastatR) library(dplyr) df_asg <- all_star_games(include_aba = FALSE, return_message = TRUE) df_asg %>% count(namePlayerMVP, sort = TRUE) %>% head(5) # Most frequent All-Star Game MVPs df_asg %>% select(yearSeason, dateGame, locationGame, teamWinner, ptsWinner, teamLoser, ptsLoser, namePlayerMVP) %>% arrange(desc(yearSeason)) %>% head(5) ``` -------------------------------- ### Get NBA Game Logs Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/game_logs.html Retrieves NBA game logs for a specified season and result types. Ensure the 'team' and 'player' result types are correctly formatted as a character vector. ```R game_logs(seasons = 2019, result_types = c("team", "player")) ``` -------------------------------- ### Get Player Career Statistics Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/players_careers.html Use this function to retrieve career statistics for specified NBA players. You can choose between 'Totals' and 'PerGame' modes. Ensure the player names are accurate. ```R players_careers( players = c("Joe Harris", "Myles Turner", "Spencer Dinwiddie"), modes = c("Totals", "PerGame") ) ``` -------------------------------- ### Get NBA Draft Data Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/drafts.html Retrieves NBA draft data for a specified range of years. Use nest_data = FALSE for a flat tibble and return_message = TRUE to see a progress message. ```r library(dplyr) df_drafts <- drafts(draft_years = 1983:2018, nest_data = FALSE, return_message = TRUE) ``` -------------------------------- ### Get Player Season Stats Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/bref_players_stats.html Retrieves player statistics for specified seasons and table types. Use this to fetch advanced and totals data for players across multiple seasons. ```R bref_players_stats(seasons = 2017:2018, tables = c("advanced", "totals")) ``` -------------------------------- ### Acquire NBA Player Agents Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/agents_players.html Use this function to fetch NBA player agent data. Specify agent names or set `all_agents` to TRUE to get all available data. Returns a tibble. ```r agents_players( agents = "Jeff Schwartz", all_agents = FALSE, return_message = FALSE ) ``` -------------------------------- ### Fetch team rosters for multiple seasons Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/seasons_rosters.html Use the seasons_rosters function to retrieve a data frame containing rosters for the specified NBA seasons. This example fetches data for seasons 2015 through 2018. ```r df_rosters <- seasons_rosters(2015:2018) ``` -------------------------------- ### Get NBA Transactions by Team Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/pst_transaction.html Retrieves all transactions for a specified team. Set person to NULL to get team-wide transactions. ```R pst_transaction(person = NULL, team = "Nets") ``` -------------------------------- ### Enable Parallel Processing with future/furrr Source: https://github.com/abresler/nbastatr/blob/master/CLAUDE.md Demonstrates setting up parallel processing using `future` and `plan(multisession)`. This allows functions like `game_logs` to run operations concurrently for improved performance. ```r library(future) plan(multisession) game_logs(seasons = 2010:2019) # Runs in parallel ``` -------------------------------- ### Get NBA Game Win Probabilities Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/win_probability.html Retrieves NBA in-game win probabilities for specified game IDs. Use this function to get win probability data for one or more games. ```R win_probability( game_ids = c(21700002, 21700005), filter_non_plays = T, nest_data = FALSE, return_message = TRUE ) ``` -------------------------------- ### bref_bios Function Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/bref_bios.html Retrieves player bios, salaries, contracts, and transactions from Basketball Reference. ```APIDOC ## Function: bref_bios ### Description Retrieves player bios, salaries, contracts, and transactions from Basketball Reference. ### Parameters #### players - (vector) - A vector of player names. #### player_ids - (vector) - A vector of Basketball Reference player IDs. #### assign_to_environment - (boolean) - If TRUE, assigns each table to the environment. #### return_message - (boolean) - If TRUE, returns a message. ### Value - (tibble) - A tibble containing player data. ### Examples ```R if (FALSE) { bref_bios( players = c("Jarrett Allen", "Mitch Richmond", "Michael Adams"), player_ids = NULL, assign_to_environment = TRUE) } ``` ``` -------------------------------- ### Get Player Seasons Data Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/seasons_players.html Use this function to retrieve player data for a range of NBA seasons. Set nest_data to TRUE to get a nested tibble, and return_message to TRUE to display a progress message. ```R seasons_players(seasons = 1960:2018, nest_data = F, return_message = T) ``` ```R seasons_players(2010:2017, nest_data = T, return_message = T) ``` -------------------------------- ### Get NBA Scores for a Specific Date Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/days_scores.html Use this function to retrieve NBA scores for a particular date. Set include_standings to TRUE to also get the standings for that day. The return_message argument controls whether a confirmation message is displayed. ```R days_scores(game_dates = "2017-12-31", include_standings = F, return_message = T) ``` -------------------------------- ### Call nbastats_api_parameters with specific API versions Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nbastats_api_parameters.html Shows how to specify particular API versions when calling the `nbastats_api_parameters` function. This allows for targeted retrieval of API parameter information. ```r nbastats_api_parameters(1:3) ``` -------------------------------- ### Call nbastats_api_parameters with default arguments Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nbastats_api_parameters.html Demonstrates how to call the `nbastats_api_parameters` function with its default arguments. This function is used to retrieve information about NBA Stats API versions. ```r nbastats_api_parameters(api_versions = 1:3) ``` -------------------------------- ### Get Current NBA Schedule Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/current_schedule.html Retrieves the NBA schedule for the most current season. Returns a tibble. ```APIDOC ## current_schedule() ### Description Get NBA schedule for most current season. ### Returns A `tibble` containing the current season's schedule. ### Example ```r current_schedule() ``` ``` -------------------------------- ### Retrieve Player Bios using Names Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/bref_bios.html Use this function to fetch bios for specific players by their names. Ensure the player names are correctly spelled as they appear on Basketball Reference. The function can optionally assign tables to the environment. ```R bref_bios( players = c("Jarrett Allen", "Mitch Richmond", "Michael Adams"), player_ids = NULL, assign_to_environment = TRUE) ``` -------------------------------- ### Fetch Player Game Logs with nbastatR Source: https://context7.com/abresler/nbastatr/llms.txt Retrieve player game-by-game logs for specified seasons and league. Results can be assigned to the global environment and returned with a message. ```r library(nbastatR) library(dplyr) # Fetch player game logs for 2019 and 2020 regular seasons logs <- game_logs( seasons = 2019:2020, league = "NBA", result_types = "player", season_types = "Regular Season", assign_to_environment = TRUE, return_message = TRUE ) # dataGameLogsPlayer is also in .GlobalEnv dataGameLogsPlayer %>% filter(namePlayer == "LeBron James") %>% select(dateGame, slugMatchup, pts, reb, ast, plusminus) %>% head(5) # Expected columns: dateGame, slugMatchup, pts, reb, ast, plusminus ``` ```r # Fetch both player and team logs with parallel computing library(future) plan(multisession) game_logs( seasons = 2010:2019, result_types = c("player", "team"), season_types = c("Regular Season", "Playoffs") ) ``` -------------------------------- ### Fetch Basketball-Reference Coach Dictionary Source: https://context7.com/abresler/nbastatr/llms.txt Retrieves a dictionary of Basketball-Reference coach data. Useful for filtering active coaches and their career seasons. ```r # BREF coach dictionary df_coaches <- dictionary_bref_coaches() df_coaches %>% filter(isActiveCoach == TRUE) %>% select(nameCoach, slugCoachBREF, slugSeasons) %>% head(5) ``` -------------------------------- ### team_season_roster Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/team_season_roster.html Gets the team roster for a specified season. This function allows users to fetch historical roster data for any NBA team. ```APIDOC ## team_season_roster ### Description Gets teams roster from a specified season. ### Function Signature `team_season_roster(team = "Denver Nuggets", season = 2015, return_message = TRUE)` ### Arguments * **team** (character) - The name of the team for which to retrieve the roster. * **season** (numeric vector) - The season(s) for which to retrieve the roster. For example, `2015` or `c(2015, 2016)`. * **return_message** (logical) - If TRUE, a message is returned indicating the progress. Defaults to TRUE. ### Value A `tibble` containing the team's roster for the specified season(s). ### See Also Other rosters: `seasons_rosters()`, `teams_rosters()` ### Examples ```R # Get the roster for the Denver Nuggets in the 1991 season team_season_roster(team = "Denver Nuggets", season = 1991) ``` ``` -------------------------------- ### nbadraftnet_mock_drafts function signature Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nbadraftnet_mock_drafts.html Returns mock drafts from nbadraft.net for specified years. Arguments control the years to fetch, whether to merge NBA player data, how to structure the output (nested or flat), and whether to display a progress message. ```R nbadraftnet_mock_drafts( years = 2009:2018, merge_nba_data = TRUE, nest_data = FALSE, return_message = TRUE ) ``` -------------------------------- ### nba_player_ids Function Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nba_player_ids.html Resolves player IDs for specified players. You can provide either player names or their IDs to get the corresponding information. ```APIDOC ## nba_player_ids ### Description Resolve player ids for specified players. ### Arguments - `players` (vector of player names) - Optional. A vector of player names to look up. - `player_ids` (vector of player ids) - Optional. A vector of player IDs to look up. ### Value A `tibble` containing player ID information. ### See Also Other ids: `nba_teams_ids()` ### Examples ```R nba_player_ids(players = c("Mitch Richmond", "Kyle Kuzma")) ``` ``` -------------------------------- ### dictionary_bref_coaches() Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/dictionary_bref_coaches.html Retrieves the Basketball Reference coach dictionary as a tibble. ```APIDOC ## dictionary_bref_coaches() ### Description Retrieves the Basketball Reference coach dictionary. ### Value A `tibble` containing coach data. ### Examples ```R dictionary_bref_coaches() ``` ``` -------------------------------- ### Get NBA Franchise History Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nba_franchise_history.html Acquires history for all NBA franchises. This function returns a tibble containing franchise history data. ```APIDOC ## nba_franchise_history ### Description Acquires history for all NBA franchises. ### Function Signature nba_franchise_history(return_message = TRUE, only_active = FALSE) ### Arguments - **return_message** (logical) - If TRUE, returns a message. Defaults to TRUE. - **only_active** (logical) - If TRUE, only active teams are returned. Defaults to FALSE. ### Value A `[tibble()](https://tibble.tidyverse.org/reference/tibble.html)` containing franchise history data. ### Examples ```R nba_franchise_history() ``` ``` -------------------------------- ### Fetch Basketball-Reference Team Dictionary Source: https://context7.com/abresler/nbastatr/llms.txt Retrieves a dictionary of Basketball-Reference team data. Use this to filter active teams and their first/last seasons. ```r # BREF team dictionary df_teams_bref <- dictionary_bref_teams() df_teams_bref %>% filter(isActiveTeam == TRUE) %>% select(nameTeamBREF, slugTeamBREF, seasonFirst, seasonLast) %>% head(5) ``` -------------------------------- ### Fetch Season Schedule with nbastatR Source: https://context7.com/abresler/nbastatr/llms.txt Retrieve the full schedule for specified seasons, optionally including parsed box scores. Results are returned with a message. ```r library(nbastatR) # Get the 2018 and 2019 regular season schedules sched <- seasons_schedule( seasons = c(2018, 2019), season_types = "Regular Season", return_message = TRUE ) sched %>% select(dateGame, idGame, slugMatchup, slugTeamWinner, slugTeamLoser) %>% head(5) # Expected columns: dateGame, idGame, slugMatchup, slugTeamWinner, slugTeamLoser ``` -------------------------------- ### Current Standings Source: https://context7.com/abresler/nbastatr/llms.txt Fetches the current season's NBA standings with win/loss records and percentages. ```APIDOC ## Current Standings — `current_standings()` ### Description Fetches the current season's NBA standings with win/loss records and percentages. ### Parameters - `return_message` (logical) - Whether to return a message indicating completion. ### Request Example ```r library(nbastatr) standings <- current_standings(return_message = TRUE) ``` ### Response Example ```r standings %>% arrange(desc(pctWins)) %>% select(nameTeam, slugTeam, wins, losses, pctWins, gamesBehind) %>% head(10) ``` ``` -------------------------------- ### scale_per_minute Function Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/scale_per_minute.html This function takes a data frame and a vector of column names to scale, returning the data frame with specified columns summarised per minute. ```APIDOC ## scale_per_minute ### Description Summarise data per minute. ### Arguments * `data` (data frame) - The input data frame. * `scale_columns` (vector of columns) - The columns to scale. ### Value Returns the data frame with specified columns scaled per minute. ``` -------------------------------- ### Get NBA Award Winners Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/bref_awards.html Fetches award winners for specified NBA awards. Set `return_message` to TRUE to receive a confirmation message. ```R bref_awards( awards = c("Most Valuable Player", "Rookie of the Year", "Defensive Player of the Year", "Sixth Man of the Year", "Most Improved Player", "Teammate of the Year", "J. Walter Kennedy Citizenship Award", "NBA Finals Most Valuable Player", "ABA Playoffs Most Valuable Player", "All-Star Game Most Valuable Player", "Comeback Player of the Year", "Sporting News MVP", "Sporting News Rookie of the Year", "Coach of the Year", "Executive of the Year"), return_message = TRUE ) ``` -------------------------------- ### Get Active NBA Player Injuries Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/bref_injuries.html Call the `bref_injuries()` function to retrieve a tibble containing information about active NBA player injuries. ```r bref_injuries() ``` -------------------------------- ### Retrieve Box Scores with nbastatR Source: https://context7.com/abresler/nbastatr/llms.txt Get traditional and advanced box scores for specific game IDs. Results are joined and can be assigned to the global environment. ```r library(nbastatR) # Get traditional + advanced box scores for two games bs <- box_scores( game_ids = c(21700002, 21700003), league = "NBA", box_score_types = c("Traditional", "Advanced", "Scoring", "Usage"), result_types = c("player", "team"), join_data = TRUE, assign_to_environment = TRUE, return_message = TRUE ) # Creates dataBoxScorePlayerNBA and dataBoxScoreTeamNBA in .GlobalEnv dataBoxScorePlayerNBA %>% select(idGame, namePlayer, slugTeam, pts, pctTrueShooting, pctUSG) %>% arrange(desc(pts)) %>% head(10) ``` -------------------------------- ### Get Rotowire News for a Specific Team Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/teams_rotowire.html Use this function to fetch Rotowire news for a given team. Ensure the team name is correctly specified. ```R teams_rotowire(teams = "Brooklyn Nets") ``` -------------------------------- ### Fetch Basketball-Reference Player Dictionary Source: https://context7.com/abresler/nbastatr/llms.txt Retrieves a dictionary of Basketball-Reference player data. Use this to join external data or to filter for active players and their career spans. ```r library(nbastatR) # Full Basketball-Reference player dictionary (scraped live) df_players_bref <- dictionary_bref_players() df_players_bref %>% filter(isActive == TRUE) %>% select(namePlayerBREF, slugPlayerBREF, yearsPlayer, slugSeasonRookie, slugSeasonLast) %>% head(5) ``` -------------------------------- ### Get NBA Transactions Since 2012 Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/transactions.html Acquires all NBA transactions since 2012. Use this function to retrieve a tibble containing transaction data. ```r transactions(include_history = T) ``` ```r transactions() ``` -------------------------------- ### players_bios Function Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/players_bios.html Retrieves player biographies from NBA.com. It can filter by player names or IDs and control data nesting and message returns. ```APIDOC ## players_bios ### Description Player biographies. ### Arguments - **players** (vector) - vector of players - **player_ids** (vector) - vector of player ids - **nest_data** (logical) - if TRUE returns nested tibble - **return_message** (logical) - if TRUE returns a message ### Value a `tibble` ### Details Seems to only work for the 2013-14 season ### Examples ```R players_bios(players = c("Carmelo Anthony", "Joe Johnson")) ``` ``` -------------------------------- ### Load nbastatR and dplyr libraries Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/seasons_rosters.html Before using the seasons_rosters function, ensure that the nbastatR and dplyr libraries are loaded into your R session. ```r library(nbastatR) library(dplyr) ``` -------------------------------- ### Get NBA Players Agents Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/players_agents.html Retrieves a tibble containing information about NBA players and their agents. The function can optionally return a message with player URLs. ```APIDOC ## players_agents() ### Description Retrieves a tibble containing information about NBA players and their agents. ### Arguments * `nest_data` (logical) - If TRUE, data will be nested. Defaults to FALSE. * `return_message` (logical) - If TRUE, returns player URLs. Defaults to TRUE. ### Value A `tibble()` containing player agent data. ### Examples ```R library(dplyr) df_players_agents <- players_agents() df_players_agents %>% glimpse() ``` ``` -------------------------------- ### players_careers Function Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/players_careers.html Fetches NBA player career statistics. Allows specifying players by name or ID, and choosing between 'Totals', 'PerGame', or 'Per36' modes. ```APIDOC ## players_careers ### Description NBA player career statistics for specified players and inputs. ### Signature ```r players_careers( players = NULL, player_ids = NULL, modes = c("PerGame", "Totals"), assign_to_environment = TRUE, add_mode_names = TRUE, return_message = TRUE ) ``` ### Arguments * `players` (vector or NULL): A vector of NBA player names. * `player_ids` (vector or NULL): A vector of NBA Player IDs. * `modes` (vector): A vector of statistics modes to retrieve. Can include "Totals", "PerGame", "Per36". * `assign_to_environment` (logical): If TRUE, assigns tables to the environment with names starting with 'data'. * `add_mode_names` (logical): If TRUE, adds the type of mode to the table data. * `return_message` (logical): If TRUE, returns a message indicating completion. ### Value A `tibble` containing the player career statistics. ### Examples ```r players_careers(players = c("Joe Harris", "Myles Turner", "Spencer Dinwiddie"), modes = c("Totals", "PerGame")) ``` ``` -------------------------------- ### Get NBA Team Season Data Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/nba_teams_seasons.html Call the nba_teams_seasons function to retrieve a tibble containing NBA team season statistics. No arguments are required. ```R nba_teams_seasons() ``` -------------------------------- ### assign_nba_players Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/assign_nba_players.html Assigns the NBA player dictionary to the environment. ```APIDOC ## assign_nba_players ### Description Assigns the NBA player dictionary to a tibble named `df_dict_nba_players` in your environment. ### Method `assign_nba_players()` ### Parameters This function does not take any parameters. ### Value Returns a `tibble` which is assigned to `df_dict_nba_players` in the environment. ### Examples ```r assign_nba_players() ``` ``` -------------------------------- ### Get Summer League Players Data Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/sl_players.html Call the sl_players function without arguments to retrieve data for the default year. The function returns a nested tibble. ```R sl_players() ``` -------------------------------- ### Get Player RotoWire News Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/players_rotowire.html Retrieves RotoWire news for a list of players. Specify players by name or ID. The results can be nested and limited by the 'results' argument. ```r players_rotowire(players = c( "Jarrett Allen", "DeMarre Carroll", "Allen Crabbe")) ``` -------------------------------- ### current_standings Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/current_standings.html Acquires the current season's NBA standings. It returns a tibble containing the standings data. ```APIDOC ## current_standings ### Description Acquires the current season's NBA standings. ### Arguments * `return_message` (logical) - Optional. If `TRUE`, returns a message. Defaults to `TRUE`. ### Value A `tibble` containing the current season's standings. ### Examples ```R current_standings() ``` ``` -------------------------------- ### play_by_play_v2 Function Source: https://github.com/abresler/nbastatr/blob/master/docs/reference/play_by_play_v2.html Retrieves play-by-play information for specified NBA games using the playbyplayv2 endpoint. It accepts game IDs, a flag to nest data, and a flag to return a message. ```APIDOC ## play_by_play_v2 ### Description Returns play-by-play information using the playbyplayv2 endpoint. ### Arguments #### `game_ids` - (vector) - A vector of game IDs for which to retrieve play-by-play data. #### `nest_data` - (logical) - If `TRUE`, the returned data will be nested. #### `return_message` - (logical) - If `TRUE`, a message will be returned. ### Value - A `tibble` containing the play-by-play data. ```