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:
1 parent
088771a9cf
commit
b42b866a8c
110 files changed
+400895
No files matched your search
@@ -0,0 +1,32 @@
|
||||
library(readr)
|
||||
library(dplyr)
|
||||
|
||||
|
||||
#
|
||||
# Load data
|
||||
#
|
||||
|
||||
players <- read_csv("data/nba-players-2013-14.csv")
|
||||
|
||||
|
||||
#
|
||||
# Density plot
|
||||
#
|
||||
|
||||
# Calculate density coordinates
|
||||
pdens <- density(players$Ht_inches)
|
||||
|
||||
# Plot
|
||||
par(las = 1)
|
||||
plot(pdens, lwd = 2,
|
||||
main = "NBA Player Height")
|
||||
polygon(pdens,
|
||||
col = "lightblue")
|
||||
|
||||
# Max point
|
||||
i <- which.max(pdens$y)
|
||||
abline(v = pdens$x[i],
|
||||
lty = 2)
|
||||
points(pdens$x[i], pdens$y[i],
|
||||
pch = 21,
|
||||
bg = "black")
|
||||
Reference in new issue
Block a user