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,63 @@
# install.packages(c("readr", "dplyr"))
library(readr)
library(dplyr)
#
# Load data
#
players <- read_csv("data/nba-players-2013-14.csv")
heights <- players %>% select(Name, POS, Ht_inches)
# Summary statistics
summary(players$Ht_inches)
#
# Box plot
#
par(las = 1)
boxplot(players$Ht_inches,
main = "NBA Player Height, Inches")
#
# Box plot by position
#
# Multiple charts
ppos <- unique(players$POS)
players %>% distinct(POS)
par(mfrow = c(1, length(ppos)),
mar = c(2, 2, 2, 2),
oma = c(1, 3, 2, 2),
bty = "n")
for (pos in ppos) {
curr <- players %>%
filter(POS == pos)
boxplot(curr$Ht_inches,
ylim = range(players$Ht_inches),
main = pos)
}
par(mfrow = c(1, 2), las = 1)
# Using the tilde notation
boxplot(Ht_inches ~ POS,
data = players,
ylab = "",
main = "NBA Player Height by Position")
# Reorder
players_fact <- players
players_fact$POS <-
factor(players_fact$POS,
levels = c("C", "F/C", "F", "G/F", "G"))
boxplot(Ht_inches ~ POS,
data = players_fact,
ylab = "",
main = "NBA Player Height by Position,\nOrdered")