# Run this code to load the required packages
suppressMessages(suppressWarnings(suppressPackageStartupMessages({
library(mosaic)
library(supernova)
library(fivethirtyeight)
})))
nbaplayers <- read.csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vSWOzObVF0AHcXHCxZepTDtTjhpIE4PkrrlnxK67XVxuOwt8iSqz9G-VQKwez54xZfXhYe1Yj5PlA0-/pub?gid=2123483031&single=true&output=csv", head = TRUE)
head(nbaplayers)
mean(nbaplayers$height)
str(nbaplayers)
'data.frame': 11145 obs. of 21 variables:
$ player_name : chr "Dennis Rodman" "Dwayne Schintzius" "Earl Cureton" "Ed O'Bannon" ...
$ team : chr "CHI" "LAC" "TOR" "DAL" ...
$ age : int 36 28 39 24 34 38 25 28 29 28 ...
$ height : num 198 216 206 203 206 ...
$ weight : num 99.8 117.9 95.3 100.7 108.9 ...
$ college : chr "Southeastern Oklahoma State" "Florida" "Detroit Mercy" "UCLA" ...
$ country : chr "USA" "USA" "USA" "USA" ...
$ draft_year : chr "1986" "1990" "1979" "1995" ...
$ draft_round : chr "2" "1" "3" "1" ...
$ draft_number: chr "27" "24" "58" "9" ...
$ gp : int 55 15 9 64 27 52 80 77 71 82 ...
$ pts : num 5.7 2.3 0.8 3.7 2.4 8.2 17.2 14.9 5.7 6.9 ...
$ reb : num 16.1 1.5 1 2.3 2.4 2.7 4.1 8 1.6 1.5 ...
$ ast : num 3.1 0.3 0.4 0.6 0.2 1 3.4 1.6 1.3 3 ...
$ net_rating : num 16.1 12.3 -2.1 -8.7 -11.2 4.1 4.1 3.3 -0.3 -1.2 ...
$ oreb_pct : num 0.186 0.078 0.105 0.06 0.109 0.034 0.035 0.095 0.036 0.018 ...
$ dreb_pct : num 0.323 0.151 0.102 0.149 0.179 0.126 0.091 0.183 0.076 0.081 ...
$ usg_pct : num 0.1 0.175 0.103 0.167 0.127 0.22 0.209 0.222 0.172 0.177 ...
$ ts_pct : num 0.479 0.43 0.376 0.399 0.611 0.541 0.559 0.52 0.539 0.557 ...
$ ast_pct : num 0.113 0.048 0.148 0.077 0.04 0.102 0.149 0.087 0.141 0.262 ...
$ season : chr "1996-97" "1996-97" "1996-97" "1996-97" ...
summary(nbaplayers)
net_rating <- nbaplayers$net_rating
hist(net_rating)
height <- nbaplayers$height
hist(height)
weight_pounds <- nbaplayers$weight * 2.204
hist(weight_pounds)
head(arrange(nbaplayers, (net_rating)))
head(arrange(nbaplayers, desc(pts)))
plot(nbaplayers$pts, nbaplayers$net_rating, main = "Scatterplot of player pts by net rating", xlab = "pts", ylab = 'net_rating')
colleges <- c("Harvard" , "Stanford", "Princeton", "MIT", "Yale")
filter(nbaplayers, college == colleges))
top5_colleges <- filter(nbaplayers, college == colleges)
tally(unique(top5_colleges$player_name))
length(unique(top5_colleges$player_name))
head(nbaplayers$height, 10)
short_10 <- filter(arrange(nbaplayers, desc(height)))
shortest_names <- tail(unique(short_10$player_name), 10)
shortest_names
truncate <- select(short_10, player_name, height)
unique_truncate <- unique(truncate)
tail(unique_truncate, 10)
head(unique_truncate, 10)
height <- nbaplayers$height
hist(height)
plot(nbaplayers$height, nbaplayers$net_rating, main = "Scatterplot of player height by net rating", xlab = "height", ylab = 'net_rating')