41 lines
712 B
R
41 lines
712 B
R
# install.packages("MASS")
|
|
library(MASS)
|
|
|
|
|
|
#
|
|
# Load data
|
|
#
|
|
|
|
players <- read.csv("data/nba-top50scorers-2022-23.csv")
|
|
head(players)
|
|
|
|
|
|
#
|
|
# Parallel coordinates
|
|
#
|
|
|
|
fnames <- c("MP", "FG", "FGpct", "X2Ppct", "X3Ppct", "FTpct", "PTS")
|
|
psub <- players[,fnames]
|
|
|
|
# Parallel coordinates
|
|
parcoord(psub)
|
|
|
|
# Pick out player
|
|
curr_players <- c("Joel Embiid", "Giannis Antetokounmpo",
|
|
"Stephen Curry", "LeBron James")
|
|
par(mfrow=c(2,2))
|
|
for (pl in curr_players) {
|
|
col <- rep("gray", dim(players)[1])
|
|
lwd <- rep(.5, dim(players)[1])
|
|
i <- which(players$Player == pl)
|
|
col[i] <- "blue"
|
|
lwd[i] <- 3
|
|
parcoord(psub, col=col, lwd=lwd, main=pl)
|
|
}
|
|
|
|
|
|
|
|
# Scatterplot Matrix
|
|
par(las=1)
|
|
plot(psub)
|