File:Hierarchical Clustering.png

From AWF-Wiki
Jump to: navigation, search
Full resolution(1,600 × 800 pixels, file size: 52 KB, MIME type: image/png)

An example R plot to illustrate hierarchical clustering, containing fictional data points and a dendrogram.

R Code:

## Some fictional satellite brightness values:
rm(list=ls())

set.seed(23) # just change the seed to see different outcomes!

data <- data.frame(id=1:10,
		   band.4=c(rnorm(5, mean=100, sd=20),
			    rnorm(5, mean=180, sd=10)),
		   band.5=c(rnorm(5, mean=180, sd=20),
			    rnorm(5, mean=100, sd=10)))


clust <- hclust(dist(data[,2:3]))


# plot points and cluster
png('Hierarchical_Clustering.png', width=1600, height=800,
    pointsize=30)

op <- par(mfrow=c(1,2))

plot(data$band.4, data$band.5, type='n', xlab='Band 4',
     ylab='Band 5')
text(data$band.4, data$band.5, labels=data$id, col='red')
title('Data points', line=1)
mtext('Example for hierarchical clustering', line=2.2, 
      at=1.08*max(data$band.4), cex=1.5, font=2)

par(mar=c(5,4,4.3,2)+0.1)
plot(clust, xlab='Points', ylab='Distance', sub=' ', main=,
     axes=F, col='red')

axis(2, labels=seq(0,150,50), at=seq(0,150,50))
title('Dendrogram', line=1)
box()

options(op)

dev.off()

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current15:36, 3 September 2013Thumbnail for version as of 15:36, 3 September 20131,600 × 800 (52 KB)Lburgr (Talk | contribs)An example R plot to illustrate hierarchical clustering, containing fictional data points and a dendrogram. R Code: ## Some fictional satellite brightness values: rm(list=ls()) set.seed(23) # just change the seed to see different outcomes! da...

The following page links to this file:

Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox