tests/testthat/test-espn_nba_player_stats.R

test_that("ESPN - Get NBAyer season stats", {
  skip_on_cran()
  x <- espn_nba_player_stats(athlete_id = 4433134, year = 2022)

  cols <- c(
    "athlete_id",
    "athlete_uid",
    "athlete_guid",
    "athlete_type",
    "sdr",
    "first_name",
    "last_name",
    "full_name",
    "display_name",
    "short_name",
    "weight",
    "display_weight",
    "height",
    "display_height",
    "age",
    "date_of_birth",
    "slug",
    "headshot_href",
    "headshot_alt",
    "jersey",
    "position_id",
    "position_name",
    "position_display_name",
    "position_abbreviation",
    "position_leaf",
    "linked",
    "years",
    "active",
    "contract_x_ref",
    "contract_bird_status",
    "contract_active",
    "contract_active_1",
    "contract_incoming_trade_value",
    "contract_outgoing_trade_value",
    "contract_minimum_salary_exception",
    "contract_option_type",
    "contract_salary",
    "contract_salary_remaining",
    "contract_years_remaining",
    "contract_x_ref_1",
    "contract_x_ref_2",
    "contract_trade_kicker_active",
    "contract_trade_kicker_percentage",
    "contract_trade_kicker_value",
    "contract_trade_kicker_trade_value",
    "contract_trade_restriction",
    "contract_unsigned_foreign_pick",
    "contract_active_2",
    "draft_display_text",
    "draft_round",
    "draft_year",
    "draft_selection",
    "draft_x_ref",
    "draft_x_ref_1",
    "status_id",
    "status_name",
    "status_type",
    "status_abbreviation",
    "general_disqualifications",
    "general_flagrant_fouls",
    "general_fouls",
    "general_per",
    "general_rebound_rate",
    "general_ejections",
    "general_technical_fouls",
    "general_rebounds",
    "general_vorp",
    "general_warp",
    "general_rpm",
    "general_minutes",
    "general_avg_minutes",
    "general_nba_rating",
    "general_plus_minus",
    "general_avg_rebounds",
    "general_avg_fouls",
    "general_avg_flagrant_fouls",
    "general_avg_technical_fouls",
    "general_avg_ejections",
    "general_avg_disqualifications",
    "general_assist_turnover_ratio",
    "general_steal_foul_ratio",
    "general_block_foul_ratio",
    "general_avg_team_rebounds",
    "general_total_rebounds",
    "general_total_technical_fouls",
    "general_team_assist_turnover_ratio",
    "general_steal_turnover_ratio",
    "general_avg48rebounds",
    "general_avg48fouls",
    "general_avg48flagrant_fouls",
    "general_avg48technical_fouls",
    "general_avg48ejections",
    "general_avg48disqualifications",
    "general_r40",
    "general_games_played",
    "general_games_started",
    "general_double_double",
    "general_triple_double",
    "offensive_assists",
    "offensive_effective_fg_pct",
    "offensive_field_goals",
    "offensive_field_goals_attempted",
    "offensive_field_goals_made",
    "offensive_field_goal_pct",
    "offensive_free_throws",
    "offensive_free_throw_pct",
    "offensive_free_throws_attempted",
    "offensive_free_throws_made",
    "offensive_offensive_rebounds",
    "offensive_points",
    "offensive_turnovers",
    "offensive_three_point_pct",
    "offensive_three_point_field_goals_attempted",
    "offensive_three_point_field_goals_made",
    "offensive_true_shooting_pct",
    "offensive_total_turnovers",
    "offensive_assist_ratio",
    "offensive_points_in_paint",
    "offensive_off_rebound_rate",
    "offensive_turnover_ratio",
    "offensive_brick_index",
    "offensive_usage_rate",
    "offensive_avg_field_goals_made",
    "offensive_avg_field_goals_attempted",
    "offensive_avg_three_point_field_goals_made",
    "offensive_avg_three_point_field_goals_attempted",
    "offensive_avg_free_throws_made",
    "offensive_avg_free_throws_attempted",
    "offensive_avg_points",
    "offensive_avg_offensive_rebounds",
    "offensive_avg_assists",
    "offensive_avg_turnovers",
    "offensive_offensive_rebound_pct",
    "offensive_estimated_possessions",
    "offensive_avg_estimated_possessions",
    "offensive_points_per_estimated_possessions",
    "offensive_avg_team_turnovers",
    "offensive_avg_total_turnovers",
    "offensive_three_point_field_goal_pct",
    "offensive_two_point_field_goals_made",
    "offensive_two_point_field_goals_attempted",
    "offensive_avg_two_point_field_goals_made",
    "offensive_avg_two_point_field_goals_attempted",
    "offensive_two_point_field_goal_pct",
    "offensive_shooting_efficiency",
    "offensive_scoring_efficiency",
    "offensive_avg48field_goals_made",
    "offensive_avg48field_goals_attempted",
    "offensive_avg48three_point_field_goals_made",
    "offensive_avg48three_point_field_goals_attempted",
    "offensive_avg48free_throws_made",
    "offensive_avg48free_throws_attempted",
    "offensive_avg48points",
    "offensive_avg48offensive_rebounds",
    "offensive_avg48assists",
    "offensive_avg48turnovers",
    "offensive_p40",
    "offensive_a40",
    "offensive_orpm",
    "defensive_blocks",
    "defensive_defensive_rebounds",
    "defensive_steals",
    "defensive_def_rebound_rate",
    "defensive_avg_defensive_rebounds",
    "defensive_avg_blocks",
    "defensive_avg_steals",
    "defensive_avg48defensive_rebounds",
    "defensive_avg48blocks",
    "defensive_avg48steals",
    "defensive_drpm",
    "team_id",
    "team_guid",
    "team_uid",
    "team_slug",
    "team_location",
    "team_name",
    "team_abbreviation",
    "team_display_name",
    "team_short_display_name",
    "team_color",
    "team_alternate_color",
    "team_is_active",
    "team_is_all_star",
    "logo_href",
    "logo_dark_href",
    "logos_href_2",
    "logos_href_3"
  )
  expect_equal(sort(colnames(x)), sort(cols))
  expect_s3_class(x, "data.frame")

})

Try the hoopR package in your browser

Any scripts or data that you put into this service are public.

hoopR documentation built on Nov. 26, 2023, 1:07 a.m.