R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(58.972,59.249,63.955,53.785,52.760,44.795,37.348,32.370,32.717,40.974,33.591,21.124,58.608,46.865,51.378,46.235,47.206,45.382,41.227,33.795,31.295,42.625,33.625,21.538,56.421,53.152,53.536,52.408,41.454,38.271,35.306,26.414,31.917,38.030,27.534,18.387,50.556,43.901,48.572,43.899,37.532,40.357,35.489,29.027,34.485,42.598,30.306,26.451,47.460,50.104,61.465,53.726,39.477,43.895,31.481,29.896,33.842,39.120,33.702,25.094),dim=c(1,60),dimnames=list(c('Werkloosheid'),1:60)) > y <- array(NA,dim=c(1,60),dimnames=list(c('Werkloosheid'),1:60)) > 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 60 members at h = 315] |--[dendrogram w/ 2 branches and 23 members at h = 59.3] | |--[dendrogram w/ 2 branches and 16 members at h = 16.4] | | |--[dendrogram w/ 2 branches and 8 members at h = 4.15] | | | |--[dendrogram w/ 2 branches and 5 members at h = 0.343] | | | | |--[dendrogram w/ 2 branches and 2 members at h = 0.047] | | | | | |--leaf "20" | | | | | `--leaf "57" | | | | `--[dendrogram w/ 2 branches and 3 members at h = 0.114] | | | | |--leaf "59" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.034] | | | | |--leaf "11" | | | | `--leaf "23" | | | `--[dendrogram w/ 2 branches and 3 members at h = 1.16] | | | |--leaf "45" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.183] | | | |--leaf "31" | | | `--leaf "43" | | `--[dendrogram w/ 2 branches and 8 members at h = 6.11] | | |--[dendrogram w/ 2 branches and 3 members at h = 1.30] | | | |--leaf "44" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.41] | | | |--leaf "47" | | | `--leaf "56" | | `--[dendrogram w/ 2 branches and 5 members at h = 1.81] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.347] | | | |--leaf "8" | | | `--leaf "9" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.643] | | |--leaf "33" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.186] | | |--leaf "21" | | `--leaf "55" | `--[dendrogram w/ 2 branches and 7 members at h = 16.7] | |--[dendrogram w/ 2 branches and 4 members at h = 2.19] | | |--leaf "60" | | `--[dendrogram w/ 2 branches and 3 members at h = 1.46] | | |--leaf "35" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.037] | | |--leaf "32" | | `--leaf "48" | `--[dendrogram w/ 2 branches and 3 members at h = 3.79] | |--leaf "36" | `--[dendrogram w/ 2 branches and 2 members at h = 0.414] | |--leaf "12" | `--leaf "24" `--[dendrogram w/ 2 branches and 37 members at h = 152] |--[dendrogram w/ 2 branches and 15 members at h = 38.8] | |--[dendrogram w/ 2 branches and 9 members at h = 7.93] | | |--[dendrogram w/ 2 branches and 3 members at h = 1.25] | | | |--leaf "15" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.452] | | | |--leaf "37" | | | `--leaf "50" | | `--[dendrogram w/ 2 branches and 6 members at h = 2.06] | | |--[dendrogram w/ 2 branches and 3 members at h = 0.273] | | | |--leaf "27" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.059] | | | |--leaf "4" | | | `--leaf "52" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.64] | | |--leaf "26" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.352] | | |--leaf "5" | | `--leaf "28" | `--[dendrogram w/ 2 branches and 6 members at h = 8.6] | |--[dendrogram w/ 2 branches and 2 members at h = 2.49] | | |--leaf "3" | | `--leaf "51" | `--[dendrogram w/ 2 branches and 4 members at h = 3.57] | |--leaf "25" | `--[dendrogram w/ 2 branches and 3 members at h = 0.578] | |--leaf "13" | `--[dendrogram w/ 2 branches and 2 members at h = 0.277] | |--leaf "1" | `--leaf "2" `--[dendrogram w/ 2 branches and 22 members at h = 43.2] |--[dendrogram w/ 2 branches and 10 members at h = 10.8] | |--[dendrogram w/ 2 branches and 5 members at h = 2.21] | | |--leaf "39" | | `--[dendrogram w/ 2 branches and 4 members at h = 1.21] | | |--leaf "16" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.539] | | |--leaf "14" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.254] | | |--leaf "17" | | `--leaf "49" | `--[dendrogram w/ 2 branches and 5 members at h = 2.5] | |--[dendrogram w/ 2 branches and 3 members at h = 0.006] | | |--leaf "54" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.002] | | |--leaf "38" | | `--leaf "40" | `--[dendrogram w/ 2 branches and 2 members at h = 0.587] | |--leaf "6" | `--leaf "18" `--[dendrogram w/ 2 branches and 12 members at h = 14.1] |--[dendrogram w/ 2 branches and 6 members at h = 3.23] | |--[dendrogram w/ 2 branches and 2 members at h = 0.357] | | |--leaf "53" | | `--leaf "58" | `--[dendrogram w/ 2 branches and 4 members at h = 1.21] | |--[dendrogram w/ 2 branches and 2 members at h = 0.184] | | |--leaf "7" | | `--leaf "41" | `--[dendrogram w/ 2 branches and 2 members at h = 0.241] | |--leaf "30" | `--leaf "34" `--[dendrogram w/ 2 branches and 6 members at h = 3.68] |--[dendrogram w/ 2 branches and 2 members at h = 0.027] | |--leaf "22" | `--leaf "46" `--[dendrogram w/ 2 branches and 4 members at h = 1.13] |--leaf "42" `--[dendrogram w/ 2 branches and 3 members at h = 0.413] |--leaf "10" `--[dendrogram w/ 2 branches and 2 members at h = 0.227] |--leaf "19" `--leaf "29" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/19yd31228472495.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/2e15a1228472495.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) + } > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/3nm331228472496.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/4kymx1228472496.tab") + } > > system("convert tmp/19yd31228472495.ps tmp/19yd31228472495.png") > system("convert tmp/2e15a1228472495.ps tmp/2e15a1228472495.png") convert: unable to open image `tmp/2e15a1228472495.ps': No such file or directory. convert: missing an image filename `tmp/2e15a1228472495.png'. > > > proc.time() user system elapsed 0.575 0.179 0.696