R version 2.7.0 (2008-04-22) 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(493.000,481.000,462.000,457.000,442.000,439.000,488.000,521.000,501.000,485.000,464.000,460.000,467.000,460.000,448.000,443.000,436.000,431.000,484.000,510.000,513.000,503.000,471.000,471.000,476.000,475.000,470.000,461.000,455.000,456.000,517.000,525.000,523.000,519.000,509.000,512.000,519.000,517.000,510.000,509.000,501.000,507.000,569.000,580.000,578.000,565.000,547.000,555.000,562.000,561.000,555.000,544.000,537.000,543.000,594.000,611.000,613.000,611.000,594.000,595.000),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 = 1513] |--[dendrogram w/ 2 branches and 18 members at h = 270] | |--[dendrogram w/ 2 branches and 10 members at h = 65.6] | | |--[dendrogram w/ 2 branches and 4 members at h = 10.2] | | | |--leaf "53" | | | `--[dendrogram w/ 2 branches and 3 members at h = 4.33] | | | |--leaf "47" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "52" | | | `--leaf "54" | | `--[dendrogram w/ 2 branches and 6 members at h = 20.2] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "48" | | | `--leaf "51" | | `--[dendrogram w/ 2 branches and 4 members at h = 8.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "49" | | | `--leaf "50" | | `--[dendrogram w/ 2 branches and 2 members at h = 4] | | |--leaf "43" | | `--leaf "46" | `--[dendrogram w/ 2 branches and 8 members at h = 72] | |--[dendrogram w/ 2 branches and 3 members at h = 2.67] | | |--leaf "57" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "56" | | `--leaf "58" | `--[dendrogram w/ 2 branches and 5 members at h = 35.1] | |--[dendrogram w/ 2 branches and 3 members at h = 1.33] | | |--leaf "60" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "55" | | `--leaf "59" | `--[dendrogram w/ 2 branches and 2 members at h = 2] | |--leaf "44" | `--leaf "45" `--[dendrogram w/ 2 branches and 42 members at h = 731] |--[dendrogram w/ 2 branches and 17 members at h = 72.5] | |--[dendrogram w/ 2 branches and 7 members at h = 12.4] | | |--[dendrogram w/ 2 branches and 3 members at h = 3.33] | | | |--leaf "32" | | | `--[dendrogram w/ 2 branches and 2 members at h = 2] | | | |--leaf "8" | | | `--leaf "33" | | `--[dendrogram w/ 2 branches and 4 members at h = 4] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "31" | | | `--leaf "38" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "34" | | `--leaf "37" | `--[dendrogram w/ 2 branches and 10 members at h = 28.8] | |--[dendrogram w/ 2 branches and 3 members at h = 2.67] | | |--leaf "22" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "9" | | `--leaf "41" | `--[dendrogram w/ 2 branches and 7 members at h = 7.69] | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "21" | | `--leaf "36" | `--[dendrogram w/ 2 branches and 5 members at h = 3.6] | |--leaf "42" | `--[dendrogram w/ 2 branches and 4 members at h = 2] | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "20" | | `--leaf "39" | `--[dendrogram w/ 2 branches and 2 members at h = 0] | |--leaf "35" | `--leaf "40" `--[dendrogram w/ 2 branches and 25 members at h = 203] |--[dendrogram w/ 2 branches and 10 members at h = 50.4] | |--[dendrogram w/ 2 branches and 5 members at h = 10.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "25" | | | `--leaf "26" | | `--[dendrogram w/ 2 branches and 3 members at h = 1.33] | | |--leaf "27" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "23" | | `--leaf "24" | `--[dendrogram w/ 2 branches and 5 members at h = 12.1] | |--[dendrogram w/ 2 branches and 3 members at h = 4.33] | | |--leaf "2" | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "10" | | `--leaf "19" | `--[dendrogram w/ 2 branches and 2 members at h = 5] | |--leaf "1" | `--leaf "7" `--[dendrogram w/ 2 branches and 15 members at h = 110] |--[dendrogram w/ 2 branches and 6 members at h = 17.7] | |--[dendrogram w/ 2 branches and 3 members at h = 7] | | |--leaf "15" | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "5" | | `--leaf "16" | `--[dendrogram w/ 2 branches and 3 members at h = 7.67] | |--leaf "18" | `--[dendrogram w/ 2 branches and 2 members at h = 3] | |--leaf "6" | `--leaf "17" `--[dendrogram w/ 2 branches and 9 members at h = 18.2] |--[dendrogram w/ 2 branches and 3 members at h = 1.67] | |--leaf "29" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "4" | `--leaf "30" `--[dendrogram w/ 2 branches and 6 members at h = 9.5] |--[dendrogram w/ 2 branches and 4 members at h = 2.5] | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "12" | | `--leaf "14" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "3" | `--leaf "28" `--[dendrogram w/ 2 branches and 2 members at h = 3] |--leaf "11" `--leaf "13" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/18sty1228770818.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/2wnmf1228770818.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/3o46k1228770818.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/4cof21228770818.tab") + } > > system("convert tmp/18sty1228770818.ps tmp/18sty1228770818.png") > system("convert tmp/2wnmf1228770818.ps tmp/2wnmf1228770818.png") convert: unable to open image `tmp/2wnmf1228770818.ps': No such file or directory. convert: missing an image filename `tmp/2wnmf1228770818.png'. > > > proc.time() user system elapsed 2.441 0.476 2.979