R version 2.6.0 (2007-10-03) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(97.2,99.5,77.2,102.5,107.9,79.4,113.4,124.6,90.4,109.8,115,81.4,104.9,110.3,85.8,126.1,132.7,103.6,80,99.7,73.6,96.8,96.5,75.7,117.2,118.7,99.2,112.3,112.9,88.7,117.3,130.5,94.6,111.1,137.9,98.7,102.2,115,84.2,104.3,116.8,87.7,122.9,140.9,103.3,107.6,120.7,88.2,121.3,134.2,93.4,131.5,147.3,106.3,89,112.4,73.1,104.4,107.1,78.6,128.9,128.4,101.6,135.9,137.7,101.4,133.3,135,98.5,121.3,151,99,120.5,137.4,89.5,120.4,132.4,83.5,137.9,161.3,97.4,126.1,139.8,87.8,133.2,146,90.4,146.6,154.6,97.1,103.4,142.1,79.4,117.2,120.5,85),dim=c(3,32),dimnames=list(c('metaal','machines','elek.ap'),1:32)) > y <- array(NA,dim=c(3,32),dimnames=list(c('metaal','machines','elek.ap'),1:32)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par4 = 'FALSE' > par3 = 'FALSE' > par2 = 'ALL' > par1 = 'ward' > ylab = 'height' > xlab = 'cases' > main = 'Dendrogram' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa, P., (2007), Hierarchical Clustering (v1.0.1) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_hierarchicalclustering.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > par3 <- as.logical(par3) > par4 <- as.logical(par4) > if (par3 == 'TRUE'){ + dum = xlab + xlab = ylab + ylab = dum + } > x <- t(y) > hc <- hclust(dist(x),method=par1) > d <- as.dendrogram(hc) > str(d) --[dendrogram w/ 2 branches and 32 members at h = 336] |--[dendrogram w/ 2 branches and 11 members at h = 64.9] | |--[dendrogram w/ 2 branches and 7 members at h = 20.4] | | |--[dendrogram w/ 2 branches and 2 members at h = 2.21] | | | |--leaf "2" | | | `--leaf "20" | | `--[dendrogram w/ 2 branches and 5 members at h = 12.0] | | |--[dendrogram w/ 2 branches and 3 members at h = 6.81] | | | |--leaf "5" | | | `--[dendrogram w/ 2 branches and 2 members at h = 4.46] | | | |--leaf "13" | | | `--leaf "14" | | `--[dendrogram w/ 2 branches and 2 members at h = 8] | | |--leaf "4" | | `--leaf "10" | `--[dendrogram w/ 2 branches and 4 members at h = 24.8] | |--[dendrogram w/ 2 branches and 2 members at h = 3.38] | | |--leaf "1" | | `--leaf "8" | `--[dendrogram w/ 2 branches and 2 members at h = 15.6] | |--leaf "7" | `--leaf "19" `--[dendrogram w/ 2 branches and 21 members at h = 118] |--[dendrogram w/ 2 branches and 10 members at h = 40.1] | |--[dendrogram w/ 2 branches and 4 members at h = 15.9] | | |--leaf "9" | | `--[dendrogram w/ 2 branches and 3 members at h = 9.49] | | |--leaf "32" | | `--[dendrogram w/ 2 branches and 2 members at h = 7.33] | | |--leaf "3" | | `--leaf "16" | `--[dendrogram w/ 2 branches and 6 members at h = 29.5] | |--leaf "31" | `--[dendrogram w/ 2 branches and 5 members at h = 16.8] | |--leaf "12" | `--[dendrogram w/ 2 branches and 4 members at h = 11.5] | |--leaf "26" | `--[dendrogram w/ 2 branches and 3 members at h = 8.12] | |--leaf "11" | `--[dendrogram w/ 2 branches and 2 members at h = 5.11] | |--leaf "17" | `--leaf "25" `--[dendrogram w/ 2 branches and 11 members at h = 51.1] |--[dendrogram w/ 2 branches and 2 members at h = 11.0] | |--leaf "27" | `--leaf "30" `--[dendrogram w/ 2 branches and 9 members at h = 33] |--[dendrogram w/ 2 branches and 4 members at h = 15.1] | |--[dendrogram w/ 2 branches and 2 members at h = 4.74] | | |--leaf "22" | | `--leaf "23" | `--[dendrogram w/ 2 branches and 2 members at h = 5.51] | |--leaf "6" | `--leaf "21" `--[dendrogram w/ 2 branches and 5 members at h = 25.5] |--[dendrogram w/ 2 branches and 2 members at h = 9.78] | |--leaf "28" | `--leaf "29" `--[dendrogram w/ 2 branches and 3 members at h = 12.4] |--leaf "18" `--[dendrogram w/ 2 branches and 2 members at h = 11.1] |--leaf "15" `--leaf "24" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1dp5u1194013689.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > if (par4 == 'TRUE'){ + plot(d,main=main,ylab=ylab,xlab=xlab,horiz=par3, nodePar=list(pch = c(1,NA), cex=0.8, lab.cex = 0.8),type='t',center=T, sub=mysub) + } else { + plot(d,main=main,ylab=ylab,xlab=xlab,horiz=par3, nodePar=list(pch = c(1,NA), cex=0.8, lab.cex = 0.8), sub=mysub) + } > dev.off() null device 1 > if (par2 != 'ALL'){ + if (par3 == 'TRUE'){ + ylab = 'cluster' + } else { + xlab = 'cluster' + } + par2 <- as.numeric(par2) + memb <- cutree(hc, k = par2) + cent <- NULL + for(k in 1:par2){ + cent <- rbind(cent, colMeans(x[memb == k, , drop = FALSE])) + } + hc1 <- hclust(dist(cent),method=par1, members = table(memb)) + de <- as.dendrogram(hc1) + postscript(file="/var/www/html/rcomp/tmp/2s4s61194013689.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + if (par4 == 'TRUE'){ + plot(de,main=main,ylab=ylab,xlab=xlab,horiz=par3, nodePar=list(pch = c(1,NA), cex=0.8, lab.cex = 0.8),type='t',center=T, sub=mysub) + } else { + plot(de,main=main,ylab=ylab,xlab=xlab,horiz=par3, nodePar=list(pch = c(1,NA), cex=0.8, lab.cex = 0.8), sub=mysub) + } + dev.off() + str(de) + } > load(file='/var/www/html/rcomp/createtable') > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Summary of Dendrogram',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Label',header=TRUE) > a<-table.element(a,'Height',header=TRUE) > a<-table.row.end(a) > num <- length(x[,1])-1 > for (i in 1:num) + { + a<-table.row.start(a) + a<-table.element(a,hc$labels[i]) + a<-table.element(a,hc$height[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/3rqwb1194013689.tab") > if (par2 != 'ALL'){ + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Summary of Cut Dendrogram',2,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Label',header=TRUE) + a<-table.element(a,'Height',header=TRUE) + a<-table.row.end(a) + num <- par2-1 + for (i in 1:num) + { + a<-table.row.start(a) + a<-table.element(a,i) + a<-table.element(a,hc1$height[i]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/4doh81194013690.tab") + } > > system("convert tmp/1dp5u1194013689.ps tmp/1dp5u1194013689.png") > system("convert tmp/2s4s61194013689.ps tmp/2s4s61194013689.png") convert: unable to open image `tmp/2s4s61194013689.ps': No such file or directory. convert: missing an image filename `tmp/2s4s61194013689.png'. > > > proc.time() user system elapsed 1.392 0.261 1.461