[R] Cluster of iris data set from Mahalanobis distances

From: Jose Claudio Faria <joseclaudio.faria_at_terra.com.br>
Date: Sat 02 Jul 2005 - 23:15:36 EST


Dear R list,

My question:

I'm trying to calculate Mahalanobis distances for 'Species' from the iris data set as below:

cat('\n')
cat('Cluster analyse of iris data\n')
cat('from Mahalanobis distance obtained of SAS\n')
cat('\n')

n   = 3
dat = c(        0,
  	       89.86419, 	       0,
  	      179.38471, 	17.20107, 	0)

D = matrix(0, n, n)

nam = c('Set', 'Ver', 'Vir')
rownames(D) = nam
colnames(D) = nam

k = 0
for (i in 1:n) {

   for (j in 1:i) {

      k      = k+1
      D[i,j] = dat[k]
      D[j,i] = dat[k]

   }
}

D=sqrt(D) #D2 -> D

dendroS = hclust(as.dist(D), method='single') dendroC = hclust(as.dist(D), method='complete')

win.graph(w = 3.5, h = 6)
split.screen(c(2, 1))
screen(1)
plot(dendroS, main='Single', sub='', xlab='', ylab='', col='blue')

screen(2)
plot(dendroC, main='Complete', sub='', xlab='', col='red')

I'm not fouding how to make it in the CRAN documentation (Archives, packages: mclust, cluster, fpc and mva).

Could help me?

Regards,

-- 
Jose Claudio Faria
Brasil/Bahia/UESC/DCET
Estatistica Experimental/Prof. Adjunto
mails:
  joseclaudio.faria@terra.com.br

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Jul 02 23:17:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:11 EST