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(524,552,532,511,492,492,493,481,462,457,442,439,488,521,501,485,464,460,467,460,448,443,436,431,484,510,513,503,471,471,476,475,470,461,455,456,517,525,523,519,509,512,519,517,510,509,501,507,569,580,578,565,547,555,562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573,567,569,621,629,628,612,595,597,593,590,580,574,573,573,620,626,620,588,566,557,561,549,532,526,511,499,555,565,542,527,510,514,517,508,493,490,469,478),dim=c(1,108),dimnames=list(c('Werkloosheid'),1:108)) > y <- array(NA,dim=c(1,108),dimnames=list(c('Werkloosheid'),1:108)) > 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 = '20' > 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: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.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 108 members at h = 3188] |--[dendrogram w/ 2 branches and 47 members at h = 648] | |--[dendrogram w/ 2 branches and 27 members at h = 174] | | |--[dendrogram w/ 2 branches and 10 members at h = 33.5] | | | |--[dendrogram w/ 2 branches and 4 members at h = 3] | | | | |--leaf "90" | | | | `--[dendrogram w/ 2 branches and 3 members at h = 0] | | | | |--leaf "97" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | | | |--leaf "54" | | | | `--leaf "57" | | | `--[dendrogram w/ 2 branches and 6 members at h = 14.3] | | | |--[dendrogram w/ 2 branches and 3 members at h = 1.67] | | | | |--leaf "99" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | | |--leaf "58" | | | | `--leaf "60" | | | `--[dendrogram w/ 2 branches and 3 members at h = 4.67] | | | |--leaf "2" | | | `--[dendrogram w/ 2 branches and 2 members at h = 2] | | | |--leaf "53" | | | `--leaf "92" | | `--[dendrogram w/ 2 branches and 17 members at h = 68.4] | | |--[dendrogram w/ 2 branches and 9 members at h = 17.4] | | | |--[dendrogram w/ 2 branches and 3 members at h = 1.33] | | | | |--leaf "55" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | | | |--leaf "56" | | | | `--leaf "91" | | | `--[dendrogram w/ 2 branches and 6 members at h = 7.5] | | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | | |--leaf "49" | | | | `--leaf "72" | | | `--[dendrogram w/ 2 branches and 4 members at h = 2.5] | | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | | |--leaf "52" | | | | `--leaf "98" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "71" | | | `--leaf "89" | | `--[dendrogram w/ 2 branches and 8 members at h = 23.8] | | |--[dendrogram w/ 2 branches and 4 members at h = 1.5] | | | |--leaf "82" | | | `--[dendrogram w/ 2 branches and 3 members at h = 0] | | | |--leaf "84" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "70" | | | `--leaf "83" | | `--[dendrogram w/ 2 branches and 4 members at h = 6.33] | | |--leaf "69" | | `--[dendrogram w/ 2 branches and 3 members at h = 2.67] | | |--leaf "51" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "50" | | `--leaf "81" | `--[dendrogram w/ 2 branches and 20 members at h = 212] | |--[dendrogram w/ 2 branches and 10 members at h = 18.6] | | |--[dendrogram w/ 2 branches and 4 members at h = 3] | | | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | | | |--leaf "67" | | | | `--leaf "80" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "68" | | | `--leaf "88" | | `--[dendrogram w/ 2 branches and 6 members at h = 4] | | |--[dendrogram w/ 2 branches and 3 members at h = 1.33] | | | |--leaf "79" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "61" | | | `--leaf "65" | | `--[dendrogram w/ 2 branches and 3 members at h = 2.67] | | |--leaf "78" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "66" | | `--leaf "77" | `--[dendrogram w/ 2 branches and 10 members at h = 46.8] | |--[dendrogram w/ 2 branches and 4 members at h = 2.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "62" | | | `--leaf "64" | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "63" | | `--leaf "76" | `--[dendrogram w/ 2 branches and 6 members at h = 19.3] | |--[dendrogram w/ 2 branches and 3 members at h = 1.33] | | |--leaf "73" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "85" | | `--leaf "87" | `--[dendrogram w/ 2 branches and 3 members at h = 3] | |--leaf "86" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "74" | `--leaf "75" `--[dendrogram w/ 2 branches and 61 members at h = 1010] |--[dendrogram w/ 2 branches and 25 members at h = 186] | |--[dendrogram w/ 2 branches and 6 members at h = 17.7] | | |--[dendrogram w/ 2 branches and 3 members at h = 7] | | | |--leaf "21" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "11" | | | `--leaf "22" | | `--[dendrogram w/ 2 branches and 3 members at h = 7.67] | | |--leaf "24" | | `--[dendrogram w/ 2 branches and 2 members at h = 3] | | |--leaf "12" | | `--leaf "23" | `--[dendrogram w/ 2 branches and 19 members at h = 100] | |--[dendrogram w/ 2 branches and 9 members at h = 18.2] | | |--[dendrogram w/ 2 branches and 3 members at h = 1.67] | | | |--leaf "35" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "10" | | | `--leaf "36" | | `--[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 "18" | | | | `--leaf "20" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "9" | | | `--leaf "34" | | `--[dendrogram w/ 2 branches and 2 members at h = 3] | | |--leaf "17" | | `--leaf "19" | `--[dendrogram w/ 2 branches and 10 members at h = 33.6] | |--[dendrogram w/ 2 branches and 4 members at h = 2.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "29" | | | `--leaf "30" | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "33" | | `--leaf "107" | `--[dendrogram w/ 2 branches and 6 members at h = 14.7] | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "16" | | `--leaf "25" | `--[dendrogram w/ 2 branches and 4 members at h = 6] | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "31" | | `--leaf "32" | `--[dendrogram w/ 2 branches and 2 members at h = 3] | |--leaf "8" | `--leaf "108" `--[dendrogram w/ 2 branches and 36 members at h = 218] |--[dendrogram w/ 2 branches and 10 members at h = 38.3] | |--[dendrogram w/ 2 branches and 4 members at h = 3.33] | | |--leaf "96" | | `--[dendrogram w/ 2 branches and 3 members at h = 2.67] | | |--leaf "28" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "15" | | `--leaf "47" | `--[dendrogram w/ 2 branches and 6 members at h = 7.33] | |--[dendrogram w/ 2 branches and 4 members at h = 2] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "5" | | | `--leaf "6" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "7" | | `--leaf "105" | `--[dendrogram w/ 2 branches and 2 members at h = 2] | |--leaf "13" | `--leaf "106" `--[dendrogram w/ 2 branches and 26 members at h = 119] |--[dendrogram w/ 2 branches and 12 members at h = 10.9] | |--[dendrogram w/ 2 branches and 3 members at h = 1.67] | | |--leaf "102" | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "27" | | `--leaf "42" | `--[dendrogram w/ 2 branches and 9 members at h = 6.54] | |--[dendrogram w/ 2 branches and 5 members at h = 2.4] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "4" | | | `--leaf "95" | | `--[dendrogram w/ 2 branches and 3 members at h = 0] | | |--leaf "101" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "26" | | `--leaf "45" | `--[dendrogram w/ 2 branches and 4 members at h = 2.5] | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "41" | | `--leaf "46" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "48" | `--leaf "104" `--[dendrogram w/ 2 branches and 14 members at h = 45.5] |--[dendrogram w/ 2 branches and 6 members at h = 6.67] | |--[dendrogram w/ 2 branches and 3 members at h = 0] | | |--leaf "103" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "37" | | `--leaf "44" | `--[dendrogram w/ 2 branches and 3 members at h = 2.67] | |--leaf "14" | `--[dendrogram w/ 2 branches and 2 members at h = 0] | |--leaf "40" | `--leaf "43" `--[dendrogram w/ 2 branches and 8 members at h = 25.3] |--[dendrogram w/ 2 branches and 5 members at h = 4.33] | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "94" | | `--leaf "100" | `--[dendrogram w/ 2 branches and 3 members at h = 1.67] | |--leaf "39" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "1" | `--leaf "38" `--[dendrogram w/ 2 branches and 3 members at h = 6.67] |--leaf "59" `--[dendrogram w/ 2 branches and 2 members at h = 0] |--leaf "3" `--leaf "93" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1nxin1229868579.ps",horizontal=F,pagecentre=F,paper="special",width=13.888888888889,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/2fuv21229868579.ps",horizontal=F,pagecentre=F,paper="special",width=13.888888888889,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) + } --[dendrogram w/ 2 branches and 20 members at h = 616] |--[dendrogram w/ 2 branches and 10 members at h = 145] | |--[dendrogram w/ 2 branches and 5 members at h = 36.6] | | |--[dendrogram w/ 2 branches and 2 members at h = 9.33] | | | |--leaf 2 | | | `--leaf 14 | | `--[dendrogram w/ 2 branches and 3 members at h = 14.3] | | |--leaf 12 | | `--[dendrogram w/ 2 branches and 2 members at h = 7.25] | | |--leaf 13 | | `--leaf 18 | `--[dendrogram w/ 2 branches and 5 members at h = 54.6] | |--[dendrogram w/ 2 branches and 2 members at h = 5.17] | | |--leaf 15 | | `--leaf 17 | `--[dendrogram w/ 2 branches and 3 members at h = 14.2] | |--leaf 16 | `--[dendrogram w/ 2 branches and 2 members at h = 7.33] | |--leaf 19 | `--leaf 20 `--[dendrogram w/ 2 branches and 10 members at h = 167] |--[dendrogram w/ 2 branches and 4 members at h = 37] | |--leaf 8 | `--[dendrogram w/ 2 branches and 3 members at h = 17.8] | |--leaf 7 | `--[dendrogram w/ 2 branches and 2 members at h = 9.58] | |--leaf 6 | `--leaf 11 `--[dendrogram w/ 2 branches and 6 members at h = 45] |--[dendrogram w/ 2 branches and 3 members at h = 13.4] | |--leaf 3 | `--[dendrogram w/ 2 branches and 2 members at h = 6.67] | |--leaf 1 | `--leaf 9 `--[dendrogram w/ 2 branches and 3 members at h = 17.4] |--leaf 5 `--[dendrogram w/ 2 branches and 2 members at h = 9.33] |--leaf 4 `--leaf 10 > > #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/3cbni1229868579.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/45l9c1229868579.tab") + } > > system("convert tmp/1nxin1229868579.ps tmp/1nxin1229868579.png") > system("convert tmp/2fuv21229868579.ps tmp/2fuv21229868579.png") > > > proc.time() user system elapsed 0.931 0.343 1.087