Introduction:

For our week 5 discussion, we were to come forward with datasets exemplifying “untidy” data. Project 2 requires us to take 3 of the peer posted examples from Week 5, tidy the data, and then perform the analysis requested.

This portion will be focusing on NBA Rankings posted by Jacob.

nbaRankings <- read_csv("https://raw.githubusercontent.com/d-ev-craig/DATA607/main/Projects/Project2%20-%20Untidy%20Data/Ringer%20Top%20100%20NBA%20Players%20UNTIDY%20DATA%20-%20Sheet1.csv")
## Rows: 400 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): 1, 2, 3, 4, 5
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
nbaRankings
## # A tibble: 400 × 5
##    `1`                   `2`                       `3`               `4`   `5`  
##    <chr>                 <chr>                     <chr>             <chr> <chr>
##  1 Nikola Jokic          Team: DEN                 Position: BIG     Age:… Poin…
##  2 <NA>                  Field goals made: 9.3     Field goal perce… 3-po… 3-po…
##  3 <NA>                  Free throw attempts: 6.1  Free throw perce… Offe… Defe…
##  4 <NA>                  Assists: 10.0             Turnovers: 3.6    Stea… Bloc…
##  5 Giannis Antetokounmpo Team: MIL                 Position: BIG     Age:… Poin…
##  6 <NA>                  Field goals made: 11.1    Field goal perce… 3-po… 3-po…
##  7 <NA>                  Free throw attempts: 12.7 Free throw perce… Offe… Defe…
##  8 <NA>                  Assists: 5.4              Turnovers: 3.9    Stea… Bloc…
##  9 Luka Doncic           Team: DAL                 Position: GUARD   Age:… Poin…
## 10 <NA>                  Field goals made: 11.2    Field goal perce… 3-po… 3-po…
## # … with 390 more rows

Below we are going to create the columns that we need with the value the column is interested in within the rows. My idea is that as long as each column has at least one record within it that corresponds to its correct variable value, we can filter rows using string recognition. Once I filter those rows, I can create a new column and start cbinding all my columns together.

nbaRankings <- nbaRankings %>% mutate(team=nbaRankings$`2`)%>% mutate(fieldGoalsMade=nbaRankings$`2`)%>% mutate(freeThrowAttempts=nbaRankings$`2`) %>% mutate(assists=nbaRankings$`2`)

nbaRankings <- nbaRankings %>% mutate(position=nbaRankings$`3`)%>% mutate(fieldGoalPercentage=nbaRankings$`3`)%>% mutate(freeThrowPercentage=nbaRankings$`3`) %>% mutate(turnovers=nbaRankings$`3`)

nbaRankings <- nbaRankings %>% mutate(age=nbaRankings$`4`)%>% mutate(threePtrsMade=nbaRankings$`4`)%>% mutate(offRebounds=nbaRankings$`4`) %>% mutate(steals=nbaRankings$`4`)

nbaRankings <- nbaRankings %>% mutate(points=nbaRankings$`5`)%>% mutate(threePtrPercentage=nbaRankings$`5`)%>% mutate(defRebounds=nbaRankings$`5`) %>% mutate(blocks=nbaRankings$`5`)

nbaRankings <- nbaRankings[,-(2:5)]
colnames(nbaRankings)[1] <- 'playerName'
nbaRankings
## # A tibble: 400 × 17
##    playerN…¹ team  field…² freeT…³ assists posit…⁴ field…⁵ freeT…⁶ turno…⁷ age  
##    <chr>     <chr> <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>
##  1 Nikola J… Team… Team: … Team: … Team: … Positi… Positi… Positi… Positi… Age:…
##  2 <NA>      Fiel… Field … Field … Field … Field … Field … Field … Field … 3-po…
##  3 <NA>      Free… Free t… Free t… Free t… Free t… Free t… Free t… Free t… Offe…
##  4 <NA>      Assi… Assist… Assist… Assist… Turnov… Turnov… Turnov… Turnov… Stea…
##  5 Giannis … Team… Team: … Team: … Team: … Positi… Positi… Positi… Positi… Age:…
##  6 <NA>      Fiel… Field … Field … Field … Field … Field … Field … Field … 3-po…
##  7 <NA>      Free… Free t… Free t… Free t… Free t… Free t… Free t… Free t… Offe…
##  8 <NA>      Assi… Assist… Assist… Assist… Turnov… Turnov… Turnov… Turnov… Stea…
##  9 Luka Don… Team… Team: … Team: … Team: … Positi… Positi… Positi… Positi… Age:…
## 10 <NA>      Fiel… Field … Field … Field … Field … Field … Field … Field … 3-po…
## # … with 390 more rows, 7 more variables: threePtrsMade <chr>,
## #   offRebounds <chr>, steals <chr>, points <chr>, threePtrPercentage <chr>,
## #   defRebounds <chr>, blocks <chr>, and abbreviated variable names
## #   ¹​playerName, ²​fieldGoalsMade, ³​freeThrowAttempts, ⁴​position,
## #   ⁵​fieldGoalPercentage, ⁶​freeThrowPercentage, ⁷​turnovers
#Player Name and Team
playerTeam <- nbaRankings %>% filter(str_detect(nbaRankings$team, '^Team:')) %>% select(playerName,team) #filter rows by detecting strings that contain our data
playerTeam$team <- gsub('Team: ','',playerTeam$team) #clean up the string


#Field Goals Made
fGM <- nbaRankings %>% filter(str_detect(nbaRankings$fieldGoalsMade, '^Field goals made: ')) %>% select(fieldGoalsMade)  #filter rows by detecting strings that contain our data
fGM$fieldGoalsMade <- gsub('Field goals made: ','',fGM$fieldGoalsMade) #clean up the string

playerTeam <- cbind(playerTeam,fGM$fieldGoalsMade) #add our new column
colnames(playerTeam)[3] <- 'fieldGoalsMade' #ensure the name is what we want

# Repeat

#freeThrowAttempts
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$freeThrowAttempts, '^Free throw attempts: ')) %>% select(freeThrowAttempts)
fTA$freeThrowAttempts <- gsub('^Free throw attempts: ','',fTA$freeThrowAttempts)

playerTeam <- cbind(playerTeam,fTA$freeThrowAttempts)
colnames(playerTeam)[4] <- 'freeThrowAttempts'

#assists
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$assists, '^Assists: ')) %>% select(assists)
fTA$assists <- gsub('^Assists: ','',fTA$assists)

playerTeam <- cbind(playerTeam,fTA$assists)
colnames(playerTeam)[5] <- 'assists'

#position
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$position, '^Position: ')) %>% select(position)
fTA$position <- gsub('^Position: ','',fTA$position)

playerTeam <- cbind(playerTeam,fTA$position)
colnames(playerTeam)[6] <- 'position'

#fieldGoalPercentage
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$fieldGoalPercentage, '^Field goal percentage: ')) %>% select(fieldGoalPercentage)
fTA$fieldGoalPercentage <- gsub('^Field goal percentage: ','',fTA$fieldGoalPercentage)

playerTeam <- cbind(playerTeam,fTA$fieldGoalPercentage)
colnames(playerTeam)[7] <- 'fieldGoalPercentage'


#freeThrowPercentage
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$freeThrowPercentage, '^Free throw percentage: ')) %>% select(freeThrowPercentage)
fTA$freeThrowPercentage <- gsub('^Free throw percentage: ','',fTA$freeThrowPercentage)

playerTeam <- cbind(playerTeam,fTA$freeThrowPercentage)
colnames(playerTeam)[8] <- 'freeThrowPercentage'

#turnovers
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$turnovers, '^Turnovers: ')) %>% select(turnovers)
fTA$turnovers <- gsub('^Turnovers: ','',fTA$turnovers)

playerTeam <- cbind(playerTeam,fTA$turnovers)
colnames(playerTeam)[9] <- 'turnovers'

#age
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$age, '^Age: ')) %>% select(age)
fTA$age <- gsub('^Age: ','',fTA$age)

playerTeam <- cbind(playerTeam,fTA$age)
colnames(playerTeam)[10] <- 'age'


#threePtrsMade
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$threePtrsMade, '^3-pointers made: ')) %>% select(threePtrsMade)
fTA$threePtrsMade <- gsub('^3-pointers made: ','',fTA$threePtrsMade)

playerTeam <- cbind(playerTeam,fTA$threePtrsMade)
colnames(playerTeam)[11] <- 'threePtrsMade'

#offRebounds
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$offRebounds, '^Offensive rebounds: ')) %>% select(offRebounds)
fTA$offRebounds <- gsub('^Offensive rebounds: ','',fTA$offRebounds)

playerTeam <- cbind(playerTeam,fTA$offRebounds)
colnames(playerTeam)[12] <- 'offRebounds'

#steals
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$steals, '^Steals: ')) %>% select(steals)
fTA$steals <- gsub('^Steals: ','',fTA$steals)

playerTeam <- cbind(playerTeam,fTA$steals)
colnames(playerTeam)[13] <- 'steals'

#points
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$points, '^Points: ')) %>% select(points)
fTA$points <- gsub('^Points: ','',fTA$points)

playerTeam <- cbind(playerTeam,fTA$points)
colnames(playerTeam)[14] <- 'points'

#threePtrPercentage
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$threePtrPercentage, '^3-pointer percentage: ')) %>% select(threePtrPercentage)
fTA$threePtrPercentage <- gsub('^3-pointer percentage: ','',fTA$threePtrPercentage)

playerTeam <- cbind(playerTeam,fTA$threePtrPercentage)
colnames(playerTeam)[15] <- 'threePtrPercentage'

#defRebounds
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$defRebounds, '^Defensive rebounds: ')) %>% select(defRebounds)
fTA$defRebounds <- gsub('^Defensive rebounds: ','',fTA$defRebounds)

playerTeam <- cbind(playerTeam,fTA$defRebounds)
colnames(playerTeam)[16] <- 'defRebounds'

#blocks
fTA <- nbaRankings %>% filter(str_detect(nbaRankings$blocks, '^Blocks: ')) %>% select(blocks)
fTA$blocks <- gsub('^Blocks: ','',fTA$blocks)

playerTeam <- cbind(playerTeam,fTA$blocks)
colnames(playerTeam)[17] <- 'blocks'

#Final
playerTeam
##                  playerName team fieldGoalsMade freeThrowAttempts assists
## 1              Nikola Jokic  DEN            9.3               6.1    10.0
## 2     Giannis Antetokounmpo  MIL           11.1              12.7     5.4
## 3               Luka Doncic  DAL           11.2              11.1     8.2
## 4             Stephen Curry  GSW            9.8               5.4     6.4
## 5              Kevin Durant  PHX           10.5               7.3     5.3
## 6               Joel Embiid  PHI           11.0              11.8     4.1
## 7              Jayson Tatum  BOS            9.9               8.5     4.6
## 8              LeBron James  LAL           11.3               6.3     7.0
## 9             Kawhi Leonard  LAC            8.3               5.0     4.0
## 10  Shai Gilgeous-Alexander  OKC           10.2              10.6     5.7
## 11             Devin Booker  PHX            9.5               6.2     5.6
## 12           Damian Lillard  POR            9.5               9.1     7.3
## 13         Donovan Mitchell  CLE            9.4               5.3     4.8
## 14                Ja Morant  MEM            9.6               8.4     8.1
## 15          Zion Williamson  NOP            9.8               8.6     4.6
## 16            Anthony Davis  LAL            9.6               7.3     2.5
## 17             Jimmy Butler  MIA            7.2               8.2     5.0
## 18              Paul George  LAC            8.1               4.9     5.2
## 19        Tyrese Haliburton  IND            7.1               3.1    10.2
## 20             James Harden  PHI            6.6               6.5    10.7
## 21            Pascal Siakam  TOR            9.1               7.6     6.1
## 22             Jaylen Brown  BOS            9.9               5.5     3.2
## 23         Domantas Sabonis  SAC            7.1               5.5     6.9
## 24             Kyrie Irving  DAL            9.9               4.5     5.4
## 25              Bam Adebayo  MIA            8.5               5.5     3.3
## 26               Trae Young  ATL            8.4               8.8    10.2
## 27             De'Aaron Fox  SAC            9.4               6.2     6.2
## 28          Anthony Edwards  MIN            9.0               5.5     4.5
## 29           Darius Garland  CLE            7.6               4.9     7.8
## 30          Lauri Markkanen  UTA            8.5               5.8     1.8
## 31            DeMar DeRozan  CHI            9.1               7.4     5.1
## 32             Jrue Holiday  MIL            7.4               2.7     7.1
## 33            Julius Randle  NYK            8.5               6.9     4.1
## 34           Brandon Ingram  NOP            8.2               5.4     4.7
## 35        Jaren Jackson Jr.  MEM            5.9               4.2     0.9
## 36             Desmond Bane  MEM            7.5               3.6     4.1
## 37       Karl-Anthony Towns  MIN            7.3               5.0     5.3
## 38            Jarrett Allen  CLE            6.1               3.4     1.7
## 39              Evan Mobley  CLE            6.5               3.7     2.6
## 40            Jalen Brunson  NYK            8.5               5.8     6.2
## 41          Khris Middleton  MIL            4.8               2.6     4.0
## 42           Draymond Green  GSW            3.2               1.5     6.8
## 43             Jamal Murray  DEN            7.2               3.6     5.8
## 44               Chris Paul  PHX            4.8               3.2     9.0
## 45              LaMelo Ball  CHA            8.3               3.4     8.5
## 46           Andrew Wiggins  GSW            6.8               1.9     2.3
## 47            Klay Thompson  GSW            7.8               2.1     2.4
## 48              Rudy Gobert  MIN            5.1               4.6     0.9
## 49            Mikal Bridges  BKN            6.4               3.2     3.5
## 50             O.G. Anunoby  TOR            6.1               2.9     2.0
## 51          Dejounte Murray  ATL            8.4               2.5     6.1
## 52             Aaron Gordon  DEN            6.6               5.0     2.9
## 53             Jerami Grant  POR            7.1               5.3     2.3
## 54             Bradley Beal  WAS            8.7               4.4     5.2
## 55      Robert Williams III  BOS            4.0               0.9     1.6
## 56              Brook Lopez  MIL            5.6               2.1     1.2
## 57              Zach LaVine  CHI            8.4               5.5     4.0
## 58       Kristaps Porzingis  WAS            7.4               7.0     2.5
## 59              Nic Claxton  BKN            5.5               3.3     1.7
## 60             Myles Turner  IND            6.5               4.4     1.3
## 61          Anfernee Simons  POR            7.6               2.9     4.2
## 62             Marcus Smart  BOS            4.0               1.8     7.0
## 63       Michael Porter Jr.  DEN            6.1               1.9     1.0
## 64             Franz Wagner  ORL            6.9               4.2     3.5
## 65              CJ McCollum  NOP            7.9               3.1     5.9
## 66              Tyler Herro  MIA            7.5               2.9     4.4
## 67            Fred VanVleet  TOR            6.4               4.3     6.6
## 68         Bojan Bogdanovic  DET            7.2               5.2     2.6
## 69            Deandre Ayton  PHX            8.1               3.1     2.0
## 70           Paolo Banchero  ORL            6.4               7.5     3.6
## 71            Kevin Huerter  SAC            5.4               1.8     2.9
## 72               Al Horford  BOS            3.5               0.4     2.7
## 73           Scottie Barnes  TOR            6.0               3.4     4.8
## 74          Malcolm Brogdon  BOS            5.1               2.7     3.7
## 75               Kyle Kuzma  WAS            8.1               3.6     3.9
## 76            Devin Vassell  SAS            7.1               3.0     3.6
## 77              Mike Conley  MIN            3.5               2.1     7.5
## 78       Wendell Carter Jr.  ORL            5.6               3.7     2.6
## 79           Keldon Johnson  SAS            7.8               5.3     2.8
## 80             Tyrese Maxey  PHI            7.0               3.9     3.6
## 81              Josh Giddey  OKC            7.0               1.6     5.8
## 82          Cade Cunningham  DET            7.8               3.6     6.0
## 83        Spencer Dinwiddie  BKN            5.8               4.0     5.3
## 84           Christian Wood  DAL            6.4               4.2     1.7
## 85             Clint Capela  ATL            5.5               1.8     0.8
## 86              Ivica Zubac  LAC            4.0               3.1     1.1
## 87              Alex Caruso  CHI            1.9               1.2     3.2
## 88             Kevon Looney  GSW            2.9               1.8     2.5
## 89            Derrick White  BOS            4.1               2.2     3.8
## 90            Norman Powell  LAC            5.7               4.6     1.8
## 91          Jordan Clarkson  UTA            7.5               4.0     4.3
## 92           Alperen Sengun  HOU            5.9               4.0     3.7
## 93            Tobias Harris  PHI            6.1               1.6     2.5
## 94          Cameron Johnson  BKN            4.8               2.0     1.6
## 95               RJ Barrett  NYK            6.9               5.3     2.8
## 96           Nikola Vucevic  CHI            7.3               1.9     3.3
## 97             Jakob Poeltl  TOR            5.3               2.9     3.0
## 98          Jaden McDaniels  MIN            4.5               1.7     2.0
## 99            Dillon Brooks  MEM            5.5               2.3     2.5
## 100           Nicolas Batum  LAC            2.1               0.7     1.5
##     position fieldGoalPercentage freeThrowPercentage turnovers age
## 1        BIG                63.2                82.6       3.6  28
## 2        BIG                53.8                64.6       3.9  28
## 3      GUARD                50.5                73.4       3.6  23
## 4      GUARD                49.5                92.2       3.2  34
## 5    FORWARD                55.9                93.4       3.5  34
## 6        BIG                53.1                85.8       3.5  28
## 7    FORWARD                46.1                86.4       2.9  24
## 8    FORWARD                50.3                76.0       3.1  38
## 9    FORWARD                50.6                87.4       1.5  31
## 10     GUARD                50.7                90.8       2.9  24
## 11     GUARD                47.4                85.3       2.5  26
## 12     GUARD                46.7                91.6       3.2  32
## 13     GUARD                47.6                87.6       2.7  26
## 14     GUARD                46.3                74.1       3.5  23
## 15       BIG                60.8                71.4       3.4  22
## 16       BIG                56.2                81.7       2.1  29
## 17   FORWARD                51.5                84.7       1.7  33
## 18   FORWARD                46.1                86.9       3.3  32
## 19     GUARD                48.2                86.5       2.6  22
## 20     GUARD                45.2                86.4       3.4  33
## 21   FORWARD                48.0                76.7       2.5  28
## 22     GUARD                48.6                77.7       3.1  26
## 23       BIG                61.0                77.1       2.9  26
## 24     GUARD                49.2                89.6       2.3  30
## 25       BIG                54.0                79.9       2.5  25
## 26     GUARD                42.8                88.7       4.1  24
## 27     GUARD                51.4                79.0       2.7  25
## 28   FORWARD                46.3                77.9       3.4  21
## 29     GUARD                46.7                86.6       2.9  23
## 30       BIG                51.4                88.3       1.9  25
## 31   FORWARD                50.6                88.2       2.2  33
## 32     GUARD                46.5                86.3       3.0  32
## 33   FORWARD                46.4                76.0       2.8  28
## 34   FORWARD                46.0                87.9       3.3  25
## 35       BIG                49.3                78.7       1.5  23
## 36     GUARD                46.3                90.4       2.2  24
## 37       BIG                50.5                88.5       3.1  27
## 38       BIG                65.1                72.9       1.5  24
## 39       BIG                55.3                69.9       2.0  21
## 40     GUARD                48.0                83.7       2.0  26
## 41   FORWARD                42.4                93.5       2.0  31
## 42       BIG                51.7                70.0       2.6  32
## 43     GUARD                45.3                83.0       2.1  26
## 44     GUARD                43.0                82.0       2.0  37
## 45     GUARD                40.7                85.0       3.5  21
## 46   FORWARD                47.3                61.1       1.3  28
## 47     GUARD                42.6                89.0       1.7  33
## 48       BIG                67.9                67.1       1.7  30
## 49   FORWARD                46.7                89.6       1.5  26
## 50   FORWARD                45.4                82.5       2.2  25
## 51     GUARD                46.5                83.7       2.3  26
## 52   FORWARD                58.7                62.3       1.6  27
## 53   FORWARD                48.4                80.6       1.8  28
## 54     GUARD                51.8                85.7       2.8  29
## 55       BIG                75.0                65.2       0.9  25
## 56       BIG                50.9                77.4       1.4  34
## 57     GUARD                46.9                83.8       2.6  27
## 58       BIG                48.7                84.6       2.2  27
## 59       BIG                71.7                50.6       1.3  23
## 60       BIG                54.5                78.7       1.7  26
## 61     GUARD                45.0                91.3       2.2  23
## 62     GUARD                42.4                76.9       2.4  28
## 63   FORWARD                47.4                79.8       1.1  24
## 64   FORWARD                48.6                83.3       2.1  21
## 65     GUARD                43.4                79.2       2.6  31
## 66     GUARD                43.5                92.0       2.4  23
## 67     GUARD                39.4                89.3       1.9  29
## 68   FORWARD                48.7                88.3       2.3  33
## 69       BIG                59.3                73.9       1.9  24
## 70   FORWARD                41.8                75.2       2.7  20
## 71     GUARD                47.9                69.9       1.4  24
## 72       BIG                47.0                72.2       0.6  36
## 73   FORWARD                45.4                77.0       2.1  21
## 74     GUARD                48.6                88.7       1.6  30
## 75   FORWARD                45.1                71.9       3.0  27
## 76     GUARD                44.5                79.3       1.6  22
## 77     GUARD                40.6                81.2       1.7  35
## 78       BIG                51.7                73.9       2.2  23
## 79   FORWARD                44.6                77.4       2.1  23
## 80     GUARD                45.1                81.3       1.4  22
## 81     GUARD                48.0                77.5       3.0  20
## 82     GUARD                41.5                83.7       3.3  21
## 83     GUARD                44.8                82.5       1.7  29
## 84       BIG                52.6                76.3       1.9  27
## 85       BIG                62.9                61.3       0.8  28
## 86       BIG                61.7                69.9       1.7  25
## 87     GUARD                44.5                79.3       1.3  28
## 88       BIG                65.9                61.0       0.5  27
## 89     GUARD                45.7                85.9       1.1  28
## 90     GUARD                48.5                80.8       1.7  29
## 91     GUARD                44.5                81.9       3.1  30
## 92       BIG                55.5                75.3       2.5  20
## 93   FORWARD                49.9                85.6       1.3  30
## 94   FORWARD                45.3                79.1       0.5  26
## 95     GUARD                43.1                75.2       2.3  22
## 96       BIG                51.6                81.9       1.7  32
## 97       BIG                62.9                57.7       2.0  27
## 98   FORWARD                51.6                73.3       1.4  22
## 99   FORWARD                39.2                79.5       1.5  27
## 100  FORWARD                41.5                65.9       0.7  34
##     threePtrsMade offRebounds steals points threePtrPercentage defRebounds
## 1             0.8         2.2    1.3   24.5               40.2         9.4
## 2             0.8         2.3    0.8   31.3               27.0         9.7
## 3             2.7         0.9    1.5   33.2               34.7         7.9
## 4             4.9         0.6    1.0   29.4               42.7         5.8
## 5             1.8         0.4    0.8   29.7               37.6         6.4
## 6             1.1         1.8    1.1   33.1               34.0         8.6
## 7             3.3         1.1    1.0   30.4               35.5         7.6
## 8             2.2         1.2    0.9   29.6               31.0         7.3
## 9             1.8         1.2    1.4   22.7               39.6         4.9
## 10            0.9         0.9    1.6   31.0               33.8         3.9
## 11            2.2         0.8    0.9   26.5               35.1         3.8
## 12            4.2         0.6    0.8   31.4               37.2         3.7
## 13            3.6         0.9    1.5   27.0               38.2         3.1
## 14            1.6         1.1    1.1   27.0               31.7         4.8
## 15            0.2         2.0    1.1   26.0               36.8         5.0
## 16            0.4         3.3    1.1   25.6               25.0         9.1
## 17            0.5         2.2    1.9   21.9               31.2         3.7
## 18            3.0         0.7    1.4   23.5               38.8         5.5
## 19            2.9         0.6    1.7   19.8               39.9         3.0
## 20            2.9         0.5    1.2   21.6               39.3         5.7
## 21            1.4         1.8    0.8   25.3               34.1         5.9
## 22            2.5         1.3    1.1   26.5               33.6         5.8
## 23            0.4         3.0    0.9   18.8               33.8         9.3
## 24            3.3         1.0    1.0   27.1               38.2         4.0
## 25            0.0         2.6    1.2   21.4                8.3         7.2
## 26            2.2         0.7    1.0   26.9               32.9         2.2
## 27            1.6         0.5    1.1   25.3               33.2         3.8
## 28            2.7         0.6    1.6   25.0               36.5         5.3
## 29            2.5         0.4    1.3   22.0               41.7         2.2
## 30            3.0         1.8    0.6   25.2               40.9         6.7
## 31            0.5         0.4    1.0   25.2               30.7         4.2
## 32            2.4         1.3    1.3   19.5               38.2         4.0
## 33            2.8         2.1    0.7   25.1               34.5         8.5
## 34            1.7         0.4    0.7   22.8               41.3         4.6
## 35            1.5         1.7    1.1   16.7               34.8         5.0
## 36            3.0         0.7    1.0   21.3               41.6         4.2
## 37            1.8         1.7    0.8   20.8               32.5         6.5
## 38            0.0         3.2    0.8   14.7               12.5         6.7
## 39            0.3         2.3    0.8   15.9               21.1         6.5
## 40            1.9         0.6    0.9   23.7               40.7         3.0
## 41            1.4         0.6    0.7   13.5               29.9         3.2
## 42            0.6         0.9    1.0    8.1               33.0         6.5
## 43            2.4         0.8    1.0   19.9               38.8         3.3
## 44            1.6         0.4    1.6   13.7               37.6         3.8
## 45            3.9         1.2    1.3   23.4               36.7         5.2
## 46            2.4         1.6    1.2   17.1               39.6         3.4
## 47            4.4         0.7    0.7   21.9               40.8         3.2
## 48            0.0         3.2    0.8   13.4                0.0         8.4
## 49            1.9         1.1    1.2   17.6               39.6         3.4
## 50            1.9         1.5    2.0   16.6               35.5         4.0
## 51            2.0         0.7    1.5   20.8               36.2         4.9
## 52            1.0         2.4    0.8   17.3               39.7         4.4
## 53            2.3         0.9    0.8   20.8               40.6         3.5
## 54            1.7         0.8    0.9   22.9               37.2         2.7
## 55            0.0         3.2    0.5    8.5                0.0         5.5
## 56            1.8         2.0    0.5   14.6               37.5         4.6
## 57            2.8         0.5    1.0   24.1               37.3         4.4
## 58            2.1         1.9    0.9   22.8               37.6         6.7
## 59            0.0         2.5    0.8   12.7                0.0         6.5
## 60            1.7         1.6    0.6   18.1               40.2         6.4
## 61            3.5         0.3    0.7   21.4               38.1         2.4
## 62            1.8         0.7    1.4   11.2               33.0         2.8
## 63            3.0         1.0    0.7   16.8               40.6         4.4
## 64            1.7         0.9    0.9   19.0               36.8         3.1
## 65            2.8         0.8    0.9   21.0               38.2         3.5
## 66            3.1         0.5    0.9   20.7               37.4         5.3
## 67            3.0         0.5    1.6   19.7               34.4         3.8
## 68            2.4         0.6    0.6   21.4               40.2         3.2
## 69            0.1         2.8    0.6   18.7               30.4         7.3
## 70            1.1         1.2    0.9   19.7               27.7         5.4
## 71            2.6         0.6    1.1   14.8               39.2         2.8
## 72            2.1         1.2    0.5    9.3               43.0         5.0
## 73            0.9         2.3    1.0   15.6               30.2         4.8
## 74            2.1         0.7    0.6   14.7               46.5         3.6
## 75            2.6         0.9    0.5   21.4               33.5         6.6
## 76            2.8         0.2    1.2   19.4               40.4         3.8
## 77            1.8         0.4    1.0   10.6               35.6         2.0
## 78            1.2         2.1    0.4   15.1               34.9         6.5
## 79            2.1         0.9    0.7   21.8               32.4         4.0
## 80            2.2         0.4    0.8   19.4               38.0         2.4
## 81            0.9         2.0    0.8   16.1               30.4         5.8
## 82            1.4         1.0    0.8   19.9               27.9         5.2
## 83            2.5         0.3    0.8   17.5               39.6         2.8
## 84            1.7         1.3    0.4   17.7               37.5         6.7
## 85            0.0         4.2    0.7   12.1                0.0         7.0
## 86            0.0         3.3    0.4   10.2                0.0         6.8
## 87            0.8         0.6    1.6    5.5               37.7         2.5
## 88            0.0         3.1    0.6    6.8                0.0         5.9
## 89            1.8         0.6    0.7   12.0               39.1         2.7
## 90            2.1         0.4    0.8   17.2               42.4         2.6
## 91            2.6         1.2    0.5   20.9               34.1         2.9
## 92            0.2         3.1    0.8   14.9               33.3         5.6
## 93            1.8         0.9    1.0   15.5               38.3         4.9
## 94            2.6         0.7    1.0   13.8               41.2         3.0
## 95            1.8         0.9    0.5   19.7               33.0         4.3
## 96            1.6         2.1    0.7   17.8               35.6         9.4
## 97            0.0         3.4    0.9   12.3                0.0         5.7
## 98            1.2         1.3    0.9   11.4               38.2         2.6
## 99            1.8         0.6    0.8   14.6               31.3         2.6
## 100           1.6         0.9    0.6    6.2               38.3         3.4
##     blocks
## 1      0.7
## 2      0.8
## 3      0.5
## 4      0.4
## 5      1.5
## 6      1.6
## 7      0.8
## 8      0.5
## 9      0.6
## 10     1.1
## 11     0.4
## 12     0.3
## 13     0.4
## 14     0.3
## 15     0.6
## 16     2.0
## 17     0.3
## 18     0.4
## 19     0.4
## 20     0.6
## 21     0.6
## 22     0.4
## 23     0.5
## 24     0.8
## 25     0.8
## 26     0.2
## 27     0.3
## 28     0.6
## 29     0.1
## 30     0.6
## 31     0.5
## 32     0.4
## 33     0.3
## 34     0.5
## 35     3.2
## 36     0.4
## 37     0.7
## 38     1.2
## 39     1.3
## 40     0.3
## 41     0.2
## 42     0.8
## 43     0.2
## 44     0.5
## 45     0.3
## 46     0.8
## 47     0.3
## 48     1.3
## 49     0.8
## 50     0.8
## 51     0.3
## 52     0.8
## 53     0.8
## 54     0.7
## 55     1.1
## 56     2.4
## 57     0.2
## 58     1.5
## 59     2.5
## 60     2.3
## 61     0.2
## 62     0.4
## 63     0.5
## 64     0.2
## 65     0.6
## 66     0.3
## 67     0.6
## 68     0.1
## 69     0.8
## 70     0.5
## 71     0.3
## 72     0.9
## 73     0.8
## 74     0.3
## 75     0.5
## 76     0.4
## 77     0.2
## 78     0.6
## 79     0.2
## 80     0.1
## 81     0.5
## 82     0.6
## 83     0.3
## 84     1.2
## 85     1.2
## 86     1.3
## 87     0.7
## 88     0.6
## 89     0.9
## 90     0.3
## 91     0.2
## 92     0.9
## 93     0.5
## 94     0.3
## 95     0.2
## 96     0.8
## 97     1.2
## 98     1.0
## 99     0.2
## 100    0.7

There were a few questions posed for analysis in this post. The following are the ones I chose. “Are the best teams those with the most players in the top 100 regardless of placement? Or is ‘one guy’ at the top of the mountain enough?”

I’m not sure which teams are the best but what I can do is show the number of times a team appears in a graph. With some contextual knowledge of which teams are the best, a reader could determine rough tendencies.

top100Members <- playerTeam %>% arrange(team) %>% count(team) %>% arrange(desc(n))
top100Members
##    team n
## 1   BOS 7
## 2   GSW 5
## 3   LAC 5
## 4   MIN 5
## 5   TOR 5
## 6   BKN 4
## 7   CHI 4
## 8   CLE 4
## 9   DEN 4
## 10  MEM 4
## 11  MIL 4
## 12  PHI 4
## 13  PHX 4
## 14  ATL 3
## 15  DAL 3
## 16  MIA 3
## 17  NOP 3
## 18  NYK 3
## 19  ORL 3
## 20  POR 3
## 21  SAC 3
## 22  WAS 3
## 23  DET 2
## 24  IND 2
## 25  LAL 2
## 26  OKC 2
## 27  SAS 2
## 28  UTA 2
## 29  CHA 1
## 30  HOU 1

So from the chart above we can see BOS, TOR, MIN, LAC, and GSW contain the most players in the top 100. If you go to https://www.teamrankings.com/nba/ and check their ratings we see the following:

Boston : Rank 1 : 7 members
Golden State: Rank 10 : 5 members
LA Clippers : Rank 17 : 5 members
Toronto : Rank 14 : 5 members
Minnesota : Rank 18 : 5 members

Some others:

Memphis : Rank 5 : 4 members Portland : Rank 23 : 3 members Houston : Rank 29 : 1 member