This assignment consists of Loading Data into a Data Frame We needed to Write code in R Markdown to import results for analysis.
As a big fan of NBA, I chose to explore the article about “The NBA best players this season, according to RAPTOR”
This article can be found in full below: https://projects.fivethirtyeight.com/2020-nba-player-ratings/
As the results should be published in rpubs.com and GitHub, I loaded the file from its repository in GitHub and did some anaysis.
The data contained one observation with missing values (this was only Malik Newman who actually plays for the Turkish Super League) so I used na.omit function to remove it.
James Harden is likely to be the best players of the year although there are Kawhi L. and Giannis A. who could be respectively 2nd and 3rd best player when you consider the key the measure factor (raptor total) that raptor takes into consideration. Raptor total is basically the points above average per 100 possessions added by player on both offense and defense, using both box and on-off components
What I might do to extend this work is the consider some other ranking factors a how good the player is defensively and the impact that each of them brings in their respective team. As the playoffs season continue, these numbers can change and thethe finalists for the nominee are actually James H, Lebron J (ranked top 4 in raptor total), Giannis A, Kawhi L, is not selected among the three top ones.
Load data from GitHub repository
raw_data <- read.csv(("https://raw.githubusercontent.com/jnataky/The-best-NBA-players-2020/master/latest_RAPTOR_by_player.csv"))
data <-na.omit(raw_data)
Getting insight
library(tidyverse)
## -- Attaching packages --------------------------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2 v purrr 0.3.4
## v tibble 3.0.3 v dplyr 1.0.2
## v tidyr 1.1.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## -- Conflicts ------------------------------------------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
glimpse(data)
## Rows: 529
## Columns: 21
## $ player_name <chr> "Jaylen Adams", "Steven Adams", "Bam Adebayo",...
## $ player_id <chr> "adamsja01", "adamsst01", "adebaba01", "aldril...
## $ season <int> 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020...
## $ poss <int> 38, 3771, 5232, 3648, 31, 1288, 1578, 4197, 25...
## $ mp <int> 19, 1800, 2554, 1754, 13, 591, 718, 1984, 117,...
## $ raptor_box_offense <dbl> -0.1910005, 0.3577009, -1.3347453, -0.5066381,...
## $ raptor_box_defense <dbl> 6.63251927, 1.87898854, 2.18050170, 1.10698040...
## $ raptor_box_total <dbl> 6.4415187, 2.2366895, 0.8457564, 0.6003423, -9...
## $ raptor_onoff_offense <dbl> 17.3583821, -0.1512371, 3.9167539, -0.7938724,...
## $ raptor_onoff_defense <dbl> 17.7123792, 0.2099493, 0.9650876, -0.8317010, ...
## $ raptor_onoff_total <dbl> 35.07076124, 0.05871215, 4.88184144, -1.625573...
## $ raptor_offense <dbl> 3.56011629, 0.27246124, -0.35333225, -0.636506...
## $ raptor_defense <dbl> 9.3526204, 1.6299196, 2.0288464, 0.8097549, -3...
## $ raptor_total <dbl> 12.9127367, 1.9023808, 1.6755142, 0.1732484, -...
## $ war_total <dbl> 0.15522765, 4.24969439, 5.74300100, 2.58073063...
## $ war_reg_season <dbl> 0.00000000, 4.30876036, 5.33439345, 2.58073063...
## $ war_playoffs <dbl> 0.155227650, -0.059065964, 0.408607543, 0.0000...
## $ predator_offense <dbl> 3.79567744, -0.43444660, -0.01535360, -0.66789...
## $ predator_defense <dbl> 6.54780190, 1.73878312, 1.16679483, 1.26321882...
## $ predator_total <dbl> 10.3434793, 1.3043365, 1.1514412, 0.5953281, -...
## $ pace_impact <dbl> -0.88006973, -0.43317629, -0.66804019, -1.3761...
Create new data frame with columns of four ways of ratings
data_rank <-
data %>% select(player_name, war_total, raptor_total, raptor_offense, raptor_defense )
List top 10 best NBA players of this season by war_total (overall_rank)
player_rank <- data_rank %>%
arrange(desc(war_total))
top_10 <- head(player_rank, 10)
library(knitr)
kable(top_10, caption = "Top 10 NBA best players for this season" )
| player_name | war_total | raptor_total | raptor_offense | raptor_defense |
|---|---|---|---|---|
| James Harden | 17.89715 | 10.538709 | 8.6631115 | 1.8755969 |
| Kawhi Leonard | 12.81123 | 9.576968 | 6.5494253 | 3.0275422 |
| LeBron James | 12.77649 | 7.436346 | 6.3999810 | 1.0363649 |
| Giannis Antetokounmpo | 12.59835 | 9.093070 | 5.5174703 | 3.5755992 |
| Damian Lillard | 12.31041 | 6.355688 | 8.0936669 | -1.7379791 |
| Anthony Davis | 10.89472 | 6.536914 | 2.2563761 | 4.2805382 |
| Rudy Gobert | 10.78467 | 5.675656 | -0.1082776 | 5.7839334 |
| Jayson Tatum | 10.65197 | 5.883348 | 3.7789055 | 2.1044426 |
| Luka Doncic | 10.39040 | 6.282031 | 7.2953536 | -1.0133230 |
| Nikola Jokic | 10.26357 | 5.225409 | 4.6066030 | 0.6188061 |