# MinutePlot validation -- Heatmap / clustermap, underlying computations (iris)
# Install once: nothing -- this script uses base R only

# Versions (compare against those stated on this page):
cat(R.version.string, "\n")

# Load data:
d <- scale(iris[, 1:4])          # built-in; or: d <- scale(read.csv("iris.csv")[, 1:4])

# Analysis (one print per table shown on the page, in page order):
hc_var <- hclust(dist(t(d)), method = "ward.D2")
print(cbind(hc_var$merge, height = round(hc_var$height, 4)))
print(hc_var$labels[hc_var$order])
hc_row <- hclust(dist(d), method = "ward.D2")
print(cbind(hc_row$merge, height = round(hc_row$height, 4))[1:5, ])
