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(100.70 + ,101.30 + ,97.90 + ,97.60 + ,96.50 + ,96.40 + ,96.60 + ,97.00 + ,96.60 + ,96.40 + ,95.50 + ,94.70 + ,91.80 + ,89.30 + ,89.30 + ,85.90 + ,87.00 + ,83.30 + ,85.90 + ,81.50 + ,88.00 + ,85.00 + ,87.90 + ,84.80 + ,89.20 + ,87.50 + ,90.90 + ,89.00 + ,91.60 + ,90.00 + ,90.20 + ,89.60 + ,89.10 + ,87.40 + ,87.50 + ,84.80 + ,86.30 + ,81.90 + ,86.00 + ,81.10 + ,84.40 + ,79.10 + ,86.10 + ,80.50 + ,91.00 + ,88.50 + ,92.70 + ,90.90 + ,88.00 + ,84.90 + ,84.30 + ,80.00 + ,82.20 + ,76.50 + ,80.80 + ,75.40 + ,79.40 + ,73.50 + ,80.20 + ,74.30 + ,82.20 + ,77.70 + ,82.20 + ,77.90 + ,81.20 + ,76.70 + ,82.10 + ,77.20 + ,88.10 + ,86.00 + ,88.50 + ,86.90 + ,92.10 + ,92.00 + ,98.60 + ,101.70 + ,100.90 + ,104.50 + ,100.60 + ,101.70 + ,101.10 + ,100.60 + ,102.10 + ,100.30 + ,103.60 + ,102.50 + ,102.80 + ,101.00 + ,108.30 + ,108.60 + ,104.00 + ,103.40 + ,106.10 + ,106.40 + ,106.30 + ,106.60 + ,109.00 + ,108.90 + ,111.00 + ,110.50 + ,113.70 + ,114.00 + ,112.70 + ,112.80 + ,110.30 + ,109.60 + ,114.50 + ,116.00 + ,119.30 + ,124.60 + ,121.80 + ,129.00 + ,125.40 + ,131.50 + ,129.70 + ,138.60 + ,129.40 + ,138.10 + ,134.50 + ,146.30 + ,141.20 + ,157.60 + ,141.40 + ,158.40 + ,152.20 + ,176.30 + ,167.70 + ,199.90 + ,173.30 + ,210.40 + ,168.70 + ,202.60 + ,172.60 + ,207.10 + ,169.80 + ,202.00 + ,172.00 + ,203.40 + ,179.40 + ,216.30 + ,174.60 + ,207.30 + ,172.50 + ,203.50 + ,172.60 + ,204.40 + ,176.30 + ,203.70 + ,178.90 + ,205.70 + ,179.60 + ,208.00 + ,179.90 + ,209.30 + ,180.30 + ,208.70 + ,180.90 + ,206.50 + ,177.70 + ,204.50) + ,dim=c(2 + ,80) + ,dimnames=list(c('Metaal' + ,'Non-ferro') + ,1:80)) > y <- array(NA,dim=c(2,80),dimnames=list(c('Metaal','Non-ferro'),1:80)) > 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 80 members at h = 3016] |--[dendrogram w/ 2 branches and 17 members at h = 40.4] | |--[dendrogram w/ 2 branches and 6 members at h = 13.0] | | |--leaf "70" | | `--[dendrogram w/ 2 branches and 5 members at h = 4.57] | | |--[dendrogram w/ 2 branches and 3 members at h = 1.31] | | | |--leaf "76" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.721] | | | |--leaf "77" | | | `--leaf "78" | | `--[dendrogram w/ 2 branches and 2 members at h = 2.15] | | |--leaf "75" | | `--leaf "79" | `--[dendrogram w/ 2 branches and 11 members at h = 18.9] | |--[dendrogram w/ 2 branches and 3 members at h = 3.48] | | |--leaf "64" | | `--[dendrogram w/ 2 branches and 2 members at h = 1.25] | | |--leaf "66" | | `--leaf "68" | `--[dendrogram w/ 2 branches and 8 members at h = 10.6] | |--[dendrogram w/ 2 branches and 3 members at h = 3.82] | | |--leaf "65" | | `--[dendrogram w/ 2 branches and 2 members at h = 2.01] | | |--leaf "67" | | `--leaf "71" | `--[dendrogram w/ 2 branches and 5 members at h = 9.58] | |--[dendrogram w/ 2 branches and 3 members at h = 1.21] | | |--leaf "73" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.51] | | |--leaf "69" | | `--leaf "72" | `--[dendrogram w/ 2 branches and 2 members at h = 1.61] | |--leaf "74" | `--leaf "80" `--[dendrogram w/ 2 branches and 63 members at h = 754] |--[dendrogram w/ 2 branches and 31 members at h = 118] | |--[dendrogram w/ 2 branches and 14 members at h = 30.8] | | |--[dendrogram w/ 2 branches and 6 members at h = 5.19] | | | |--[dendrogram w/ 2 branches and 2 members at h = 0.906] | | | | |--leaf "21" | | | | `--leaf "26" | | | `--[dendrogram w/ 2 branches and 4 members at h = 1.22] | | | |--leaf "22" | | | `--[dendrogram w/ 2 branches and 3 members at h = 0.81] | | | |--leaf "19" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.412] | | | |--leaf "10" | | | `--leaf "20" | | `--[dendrogram w/ 2 branches and 8 members at h = 9.22] | | |--[dendrogram w/ 2 branches and 5 members at h = 1.86] | | | |--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | | | |--leaf "31" | | | | `--leaf "32" | | | `--[dendrogram w/ 2 branches and 3 members at h = 1.13] | | | |--leaf "33" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.707] | | | |--leaf "27" | | | `--leaf "34" | | `--[dendrogram w/ 2 branches and 3 members at h = 2.03] | | |--leaf "28" | | `--[dendrogram w/ 2 branches and 2 members at h = 1.13] | | |--leaf "29" | | `--leaf "30" | `--[dendrogram w/ 2 branches and 17 members at h = 30.8] | |--[dendrogram w/ 2 branches and 7 members at h = 5.32] | | |--[dendrogram w/ 2 branches and 2 members at h = 1.25] | | | |--leaf "24" | | | `--leaf "37" | | `--[dendrogram w/ 2 branches and 5 members at h = 2.02] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.728] | | | |--leaf "7" | | | `--leaf "15" | | `--[dendrogram w/ 2 branches and 3 members at h = 1.35] | | |--leaf "16" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.51] | | |--leaf "14" | | `--leaf "23" | `--[dendrogram w/ 2 branches and 10 members at h = 8.39] | |--[dendrogram w/ 2 branches and 5 members at h = 2.35] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.141] | | | |--leaf "13" | | | `--leaf "17" | | `--[dendrogram w/ 2 branches and 3 members at h = 1.33] | | |--leaf "8" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.985] | | |--leaf "35" | | `--leaf "36" | `--[dendrogram w/ 2 branches and 5 members at h = 2.68] | |--leaf "9" | `--[dendrogram w/ 2 branches and 4 members at h = 0.647] | |--leaf "18" | `--[dendrogram w/ 2 branches and 3 members at h = 0.21] | |--leaf "12" | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | |--leaf "11" | `--leaf "25" `--[dendrogram w/ 2 branches and 32 members at h = 447] |--[dendrogram w/ 2 branches and 9 members at h = 99.4] | |--[dendrogram w/ 2 branches and 3 members at h = 28.1] | | |--leaf "63" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.825] | | |--leaf "61" | | `--leaf "62" | `--[dendrogram w/ 2 branches and 6 members at h = 34] | |--[dendrogram w/ 2 branches and 3 members at h = 8.05] | | |--leaf "55" | | `--[dendrogram w/ 2 branches and 2 members at h = 4.38] | | |--leaf "56" | | `--leaf "57" | `--[dendrogram w/ 2 branches and 3 members at h = 12.3] | |--leaf "60" | `--[dendrogram w/ 2 branches and 2 members at h = 0.583] | |--leaf "58" | `--leaf "59" `--[dendrogram w/ 2 branches and 23 members at h = 110] |--[dendrogram w/ 2 branches and 9 members at h = 22.6] | |--[dendrogram w/ 2 branches and 3 members at h = 3.36] | | |--leaf "54" | | `--[dendrogram w/ 2 branches and 2 members at h = 1.56] | | |--leaf "51" | | `--leaf "52" | `--[dendrogram w/ 2 branches and 6 members at h = 9.93] | |--[dendrogram w/ 2 branches and 2 members at h = 0.283] | | |--leaf "47" | | `--leaf "48" | `--[dendrogram w/ 2 branches and 4 members at h = 3.84] | |--[dendrogram w/ 2 branches and 2 members at h = 0.762] | | |--leaf "45" | | `--leaf "49" | `--[dendrogram w/ 2 branches and 2 members at h = 1.14] | |--leaf "50" | `--leaf "53" `--[dendrogram w/ 2 branches and 14 members at h = 36.1] |--[dendrogram w/ 2 branches and 5 members at h = 3.49] | |--leaf "6" | `--[dendrogram w/ 2 branches and 4 members at h = 2.30] | |--leaf "2" | `--[dendrogram w/ 2 branches and 3 members at h = 0.772] | |--leaf "4" | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | |--leaf "3" | `--leaf "5" `--[dendrogram w/ 2 branches and 9 members at h = 7.67] |--[dendrogram w/ 2 branches and 3 members at h = 4.10] | |--leaf "39" | `--[dendrogram w/ 2 branches and 2 members at h = 0.985] | |--leaf "43" | `--leaf "46" `--[dendrogram w/ 2 branches and 6 members at h = 4.13] |--[dendrogram w/ 2 branches and 2 members at h = 0.99] | |--leaf "42" | `--leaf "44" `--[dendrogram w/ 2 branches and 4 members at h = 3.03] |--leaf "38" `--[dendrogram w/ 2 branches and 3 members at h = 1.21] |--leaf "41" `--[dendrogram w/ 2 branches and 2 members at h = 0.412] |--leaf "1" `--leaf "40" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1mwhc1194279015.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/226gc1194279016.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/3pkik1194279016.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/49bh61194279017.tab") + } > > system("convert tmp/1mwhc1194279015.ps tmp/1mwhc1194279015.png") > system("convert tmp/226gc1194279016.ps tmp/226gc1194279016.png") convert: unable to open image `tmp/226gc1194279016.ps': No such file or directory. convert: missing an image filename `tmp/226gc1194279016.png'. > > > proc.time() user system elapsed 0.917 0.208 1.005