R version 2.7.2 (2008-08-25) 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(136.5,146.4,157.7,148.7,154.6,152.1,144.8,142.1,157,159.1,164,151.5,135.9,138.5,161,151.7,142.9,157.4,138.9,141,150.9,149.9,153,144.3,128.1,123.3,155.9,144.1,134.1,153.1,131,129.8,139.9,135.6,126.8,134.4,113.5,107.5,133.8,119,125.9,130.1,114.2,111.6,131.2,124.1,127.1,123.4,100.7,100.3,121.6,110.5,110.3,122.7,102.6,101.8,113.6,107.2,116.8,112.5),dim=c(1,60),dimnames=list(c('Omzet'),1:60)) > y <- array(NA,dim=c(1,60),dimnames=list(c('Omzet'),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: 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 60 members at h = 562] |--[dendrogram w/ 2 branches and 26 members at h = 108] | |--[dendrogram w/ 2 branches and 10 members at h = 15.5] | | |--[dendrogram w/ 2 branches and 4 members at h = 2.75] | | | |--[dendrogram w/ 2 branches and 2 members at h = 0.4] | | | | |--leaf "14" | | | | `--leaf "19" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1.1] | | | |--leaf "20" | | | `--leaf "33" | | `--[dendrogram w/ 2 branches and 6 members at h = 4.63] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.8] | | | |--leaf "8" | | | `--leaf "17" | | `--[dendrogram w/ 2 branches and 4 members at h = 2.77] | | |--leaf "2" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.733] | | |--leaf "7" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | |--leaf "24" | | `--leaf "28" | `--[dendrogram w/ 2 branches and 16 members at h = 37.3] | |--[dendrogram w/ 2 branches and 8 members at h = 5.99] | | |--[dendrogram w/ 2 branches and 3 members at h = 1.93] | | | |--leaf "4" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "21" | | | `--leaf "22" | | `--[dendrogram w/ 2 branches and 5 members at h = 2.7] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | | |--leaf "23" | | | `--leaf "30" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.6] | | |--leaf "6" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | |--leaf "12" | | `--leaf "16" | `--[dendrogram w/ 2 branches and 8 members at h = 11.8] | |--[dendrogram w/ 2 branches and 5 members at h = 3.93] | | |--[dendrogram w/ 2 branches and 3 members at h = 0.633] | | | |--leaf "9" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | | | |--leaf "3" | | | `--leaf "18" | | `--[dendrogram w/ 2 branches and 2 members at h = 1.3] | | |--leaf "5" | | `--leaf "27" | `--[dendrogram w/ 2 branches and 3 members at h = 4.63] | |--leaf "11" | `--[dendrogram w/ 2 branches and 2 members at h = 1.9] | |--leaf "10" | `--leaf "15" `--[dendrogram w/ 2 branches and 34 members at h = 224] |--[dendrogram w/ 2 branches and 13 members at h = 44.4] | |--[dendrogram w/ 2 branches and 4 members at h = 2.8] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.4] | | | |--leaf "49" | | | `--leaf "50" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.8] | | |--leaf "55" | | `--leaf "56" | `--[dendrogram w/ 2 branches and 9 members at h = 12.7] | |--[dendrogram w/ 2 branches and 2 members at h = 0.3] | | |--leaf "38" | | `--leaf "58" | `--[dendrogram w/ 2 branches and 7 members at h = 6.53] | |--[dendrogram w/ 2 branches and 3 members at h = 0.833] | | |--leaf "43" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | |--leaf "37" | | `--leaf "57" | `--[dendrogram w/ 2 branches and 4 members at h = 2.75] | |--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | |--leaf "52" | | `--leaf "53" | `--[dendrogram w/ 2 branches and 2 members at h = 0.9] | |--leaf "44" | `--leaf "60" `--[dendrogram w/ 2 branches and 21 members at h = 61.4] |--[dendrogram w/ 2 branches and 7 members at h = 11.8] | |--[dendrogram w/ 2 branches and 2 members at h = 2.2] | | |--leaf "40" | | `--leaf "59" | `--[dendrogram w/ 2 branches and 5 members at h = 2.41] | |--leaf "51" | `--[dendrogram w/ 2 branches and 4 members at h = 1.22] | |--leaf "46" | `--[dendrogram w/ 2 branches and 3 members at h = 0.833] | |--leaf "54" | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | |--leaf "26" | `--leaf "48" `--[dendrogram w/ 2 branches and 14 members at h = 32] |--[dendrogram w/ 2 branches and 6 members at h = 4.7] | |--[dendrogram w/ 2 branches and 3 members at h = 0.5] | | |--leaf "36" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | | |--leaf "29" | | `--leaf "39" | `--[dendrogram w/ 2 branches and 3 members at h = 0.9] | |--leaf "1" | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | |--leaf "13" | `--leaf "34" `--[dendrogram w/ 2 branches and 8 members at h = 11.2] |--[dendrogram w/ 2 branches and 4 members at h = 1.85] | |--leaf "25" | `--[dendrogram w/ 2 branches and 3 members at h = 1.3] | |--leaf "41" | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | |--leaf "35" | `--leaf "47" `--[dendrogram w/ 2 branches and 4 members at h = 2.05] |--[dendrogram w/ 2 branches and 2 members at h = 0.2] | |--leaf "31" | `--leaf "45" `--[dendrogram w/ 2 branches and 2 members at h = 0.3] |--leaf "32" `--leaf "42" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/freestat/rcomp/tmp/13x9y1226326974.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/freestat/rcomp/tmp/23k9x1226326974.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/3db9k1226326974.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/freestat/rcomp/tmp/4u0k31226326974.tab") + } > > system("convert tmp/13x9y1226326974.ps tmp/13x9y1226326974.png") > system("convert tmp/23k9x1226326974.ps tmp/23k9x1226326974.png") convert: unable to open image `tmp/23k9x1226326974.ps': No such file or directory. convert: missing an image filename `tmp/23k9x1226326974.png'. > > > proc.time() user system elapsed 1.080 0.264 1.153