Add VT2-examples: all 6 chapters of 'Visualize This' (110 files) — data scraping, ETL, trends, categorical, multivariate, spatial, distribution analysis

This commit is contained in:
neo committed 2026-06-24 14:49:15 +05:00
1 parent 088771a9cf
commit b42b866a8c
110 files changed
+400895

No files matched your search

@@ -0,0 +1,54 @@
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")