players <-read.csv("C:/Users/Brian Faith/Desktop/Northwestern/MSDS 401 Q2/R Data/Player Performance.csv")
str(players)
## 'data.frame': 535 obs. of 28 variables:
## $ player : chr "Stephen Curry" "Chris Paul" "Russell Westbrook" "James Harden" ...
## $ salary : int 43006362 41358814 41358814 41254920 41254920 40108950 39219566 35450412 34502132 34379100 ...
## $ salary000 : int 43006 41359 41359 41255 41255 40109 39220 35450 34502 34379 ...
## $ pos : chr "PG" "PG" "PG" "PG-SG" ...
## $ age : int 32 35 32 31 30 32 36 30 33 31 ...
## $ team : chr "GSW" "PHO" "WAS" "TOT" ...
## $ games : int 63 70 65 44 40 35 45 54 51 52 ...
## $ minutes : int 2152 2199 2369 1609 1288 1157 1504 1821 1498 1745 ...
## $ PER : num 26.3 21.4 19.5 24.5 15.4 26.4 24.2 20.5 19.2 26.5 ...
## $ trueshootpct : num 0.655 0.599 0.509 0.618 0.503 0.666 0.602 0.598 0.589 0.607 ...
## $ threeptattrate: num 0.587 0.294 0.221 0.455 0.343 0.313 0.346 0.437 0.523 0.139 ...
## $ freethrowrate : num 0.289 0.206 0.334 0.44 0.291 0.395 0.31 0.239 0.222 0.565 ...
## $ orebpct : num 1.5 1.3 4.9 2.5 1.3 1.3 2.2 2.9 2.7 6.3 ...
## $ drebpct : num 15.4 14.5 28.6 20.6 9.7 21.3 23.6 18.9 9.6 17.1 ...
## $ totrebpct : num 8.5 8 16.8 11.9 5.3 11.8 12.9 11.1 6.3 11.8 ...
## $ assistpct : num 30.5 40.9 48.6 44.4 36.2 27.5 41.8 24.6 30.6 35.1 ...
## $ stealpct : num 1.7 2.2 1.7 1.6 1.5 1 1.6 1.7 2.3 3.1 ...
## $ blockpct : num 0.3 0.8 0.8 1.8 2.1 3.4 1.5 1.2 0.5 1.1 ...
## $ turnoverpct : num 12.2 14 18 16.8 14.7 14.5 15.2 14.5 12.4 10.6 ...
## $ usagepct : num 34.8 22.6 30.2 28.4 31.7 31.2 31.9 30 23.1 26.6 ...
## $ offwinshares : num 6.5 6.5 0.5 5.3 -1 3.7 3 3 4 6.6 ...
## $ defwinshares : num 2.5 2.7 3.2 1.7 0.8 1.2 2.6 2.3 2.1 2.7 ...
## $ winshares : num 9 9.2 3.7 7 -0.2 5 5.6 5.3 6.1 9.3 ...
## $ winshares48 : num 0.201 0.201 0.075 0.208 -0.007 0.206 0.179 0.139 0.197 0.255 ...
## $ offbpm : num 8.1 3.4 2.5 6.2 1.4 6.2 5.9 4 3.5 5.1 ...
## $ defbpm : num 0 1.3 0.8 0.6 -1.6 0.6 1.6 -0.4 0.9 2.5 ...
## $ bpm : num 8.1 4.7 3.4 6.8 -0.2 6.9 7.5 3.7 4.4 7.5 ...
## $ vorp : num 5.5 3.7 3.2 3.5 0.6 2.6 3.6 2.6 2.4 4.2 ...
lm(vorp~salary, data = players)
##
## Call:
## lm(formula = vorp ~ salary, data = players)
##
## Coefficients:
## (Intercept) salary
## -1.051e-01 7.671e-08
cor.test(players$vorp,players$salary, method="pearson")
##
## Pearson's product-moment correlation
##
## data: players$vorp and players$salary
## t = 19.43, df = 533, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.5914284 0.6909705
## sample estimates:
## cor
## 0.6439162
cor(players$bpm, players$salary, method="pearson")
## [1] 0.4176407
cor(players$PER, players$salary, method="pearson")
## [1] 0.4240837
cor(players$winshares, players$salary, method="pearson")
## [1] 0.5892297
NOP <- players$team == "NOP"
plot(players$winshares,players$salary000, col = ifelse(NOP, "purple","black"),
pch = ifelse(NOP, 17, 1),
cex = ifelse(NOP, 1.5, 1),
xlab = "Win Shares", ylab = "Salary $000", main = "Salary & New Orleans Win Shares")
legend("bottomright", legend = c("NOP", "League"), pch = c(17,1),
col = c("purple", "black"))
abline(lm(players$salary000~players$winshares, data = players), col = "red", lty = 3)
abline(v=4, lty = 3, col = "red")
text(10.5,10750, "Williamson", cex = .8, col = "red")
text(6,25500, "Ingram", cex = .8, col = "red")
text(5.5, 31500, "Adams", cex = .8, col = "red")
text(2.5,19500, "Bledsoe", cex = .8, col = "red")
text(4,13500, "Ball", cex = .8, col = "red")

DEN <- players$team == "DEN"
plot(players$winshares,players$salary000, col = ifelse(DEN, "blue","black"),
pch = ifelse(DEN, 17, 1),
cex = ifelse(DEN, 1.5, 1),
xlab = "Win Shares", ylab = "Salary $000", main = "Salary & Denver Win Shares")
legend("bottomright", legend = c("DEN", "League"), pch = c(17,1),
col = c("blue", "black"))
abline(lm(players$salary000~players$winshares, data = players), col = "red", lty = 3)
abline(v=4, lty = 3, col = "red")
text(15.25,27500, "Jokic", cex = .8, col = "red")
text(7,2300, "Porter", cex = .8, col = "red")
text(4,25500, "Murray", cex = .8, col = "red")

MIL <- players$team == "MIL"
plot(players$winshares,players$salary000, col = ifelse(MIL, "darkgreen","black"),
pch = ifelse(MIL, 17, 1),
cex = ifelse(MIL, 1.5, 1),
xlab = "Win Shares", ylab = "Salary $000", main = "Salary & Milwaukee Win Shares")
legend("bottomright", legend = c("MIL", "League"), pch = c(17,1),
col = c("darkgreen", "black"))
abline(lm(players$salary000~players$winshares, data = players), col = "red", lty = 3)
abline(v=4, lty = 3, col = "red")
text(11, 30000, "Antetokounmpo", cex = .8, col = "red")
text(7, 29000, "Holiday", cex = .8, col = "red")
text(7, 36000, "Middleton", cex = .8, col = "red")
text(6.25, 13000, "Lopez", cex = .8, col = "red")
text(5.75, 3500, "Portis", cex = .8, col = "red")

UTA <- players$team == "UTA"
plot(players$winshares,players$salary000, col = ifelse(UTA, "yellow","black"),
pch = ifelse(UTA, 17, 1),
cex = ifelse(UTA, 1.5, 1),
xlab = "Win Shares", ylab = "Salary $000", main = "Salary & Utah Win Shares")
legend("bottomright", legend = c("UTA", "League"), pch = c(17,1),
col = c("yellow", "black"))
abline(lm(players$salary000~players$winshares, data = players), col = "red", lty = 3)
abline(v=4, lty = 3, col = "red")
text(12,29000, "Gobert", cex = .8, col = "red")
text(7,12500, "Ingles", cex = .8, col = "red")
text(6,3500, "Mitchell", cex = .8, col = "red")
text(6,37000, "Conley", cex = .8, col = "red")
text(6.5,8500, "O'Neal", cex = .8, col = "red")
text(6.75,18000, "Bogdanovic", cex = .8, col = "red")
text(5.75,11000, "Favors", cex = .8, col = "red")
text(4.5,13500, "Clarkson", cex = .8, col = "red")

winfourcen <- players$winshares > 4 & players$pos == "C"
plot(players$winshares,players$salary000, col = ifelse(winfourcen, "red","black"),
pch = ifelse(winfourcen, 17, 1),
cex = ifelse(winfourcen, 1.5, 1),
xlab = "Win Shares", ylab = "Salary $000", main = "Salary & C Win Shares Over Four")
legend("bottomright", legend = c("C WS > 4", "League"), pch = c(17,1),
col = c("red", "black"))
abline(lm(players$salary000~players$winshares, data = players), col = "red", lty = 3)
abline(v=4, lty = 3, col = "red")
text(8,13250, "Valanciunas", cex = .8, col = "blue")
text(7.75, 7100, "Zubac", cex = .8, col = "blue")
text(6.5, 2900, "Allen", cex = .8, col = "blue")
text(6.25, 24500, "Vucevic", cex = .8, col = "blue")
text(7, 5500, "Holmes", cex = .8, col = "blue")
text(4.5, 6700, "Theis", cex = .8, col = "blue")

winfourpg <- players$winshares > 4 & players$pos == "PG"
plot(players$winshares,players$salary000, col = ifelse(winfourpg, "red","black"),
pch = ifelse(winfourpg, 17, 1),
cex = ifelse(winfourpg, 1.5, 1),
xlab = "Win Shares", ylab = "Salary $000", main = "Salary & PG Win Shares Over Four")
legend("bottomright", legend = c("PG WS > 4", "League"), pch = c(17,1),
col = c("red", "black"))
abline(lm(players$salary000~players$winshares, data = players), col = "red", lty = 3)
abline(v=4, lty = 3, col = "red")
text(11,33500, "Lillard", cex = .8, col = "blue")
text(7.5, 35500, "Irving", cex = .8, col = "blue")
text(7.25,30500, "Simmons", cex = .8, col = "blue")
text(4.5, 32500, "Lowry", cex = .8, col = "blue")
text(4.75, 23500, "Brodgon", cex = .8, col = "blue")
