Files

55 lines
1.1 KiB
R

library(readr)
library(beeswarm)
#
# Load data
#
players <- read_csv("data/nba-players-2013-14.csv")
#
# Beeswarm
#
par(las = 1)
beeswarm(players$Ht_inches,
main = "NBA Player Heights")
# By position
beeswarm(Ht_inches ~ POS,
method = "swarm",
cex = .7,
corral = "random",
pch = 21,
bg = "#00000050",
data = players,
main = "NBA Player Heights, by Position")
# By position, add noise
players$Ht_inches_rand <- players$Ht_inches +
runif(dim(players)[1], 0, 1)
beeswarm(Ht_inches_rand ~ POS,
method = "swarm",
pch = 21,
bg = c("red", "blue", "black", "purple", "darkgreen"),
data = players,
main = "NBA Player Heights, by Position")
# Highlight one player
players$col <- "#cccccc"
players$col[players$Name == "Gobert, Rudy"] <- "purple"
players$cex <- 1
players$cex[players$Name == "Gobert, Rudy"] <- 3
beeswarm(Ht_inches_rand ~ POS,
method = "swarm",
pch = 20,
pwcol = players$col,
pwcex = players$cex,
data = players,
main = "NBA Player Heights, by Position")