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(103.3,101.2,107.7,110.4,101.9,115.9,89.9,88.6,117.2,123.9,100,103.6,94.1,98.7,119.5,112.7,104.4,124.7,89.1,97,121.6,118.8,114,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89,104.4,128.9,135.9,133.3,121.3,120.5,120.4,137.9,126.1,133.2,151.1,105,119,140.4,156.6,137.1,122.7),dim=c(1,60),dimnames=list(c(''),1:60)) > y <- array(NA,dim=c(1,60),dimnames=list(c(''),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 = 452] |--[dendrogram w/ 2 branches and 32 members at h = 125] | |--[dendrogram w/ 2 branches and 9 members at h = 29.9] | | |--[dendrogram w/ 2 branches and 4 members at h = 4.22] | | | |--leaf "13" | | | `--[dendrogram w/ 2 branches and 3 members at h = 0.333] | | | |--leaf "32" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | | |--leaf "20" | | | `--leaf "25" | | `--[dendrogram w/ 2 branches and 5 members at h = 14.2] | | |--leaf "31" | | `--[dendrogram w/ 2 branches and 4 members at h = 1.33] | | |--leaf "7" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.567] | | |--leaf "8" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | |--leaf "19" | | `--leaf "43" | `--[dendrogram w/ 2 branches and 23 members at h = 66] | |--[dendrogram w/ 2 branches and 8 members at h = 6.7] | | |--[dendrogram w/ 2 branches and 4 members at h = 1.9] | | | |--[dendrogram w/ 2 branches and 2 members at h = 0.4] | | | | |--leaf "24" | | | | `--leaf "36" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.6] | | | |--leaf "4" | | | `--leaf "28" | | `--[dendrogram w/ 2 branches and 4 members at h = 1.9] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.4] | | | |--leaf "16" | | | `--leaf "34" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.6] | | |--leaf "23" | | `--leaf "27" | `--[dendrogram w/ 2 branches and 15 members at h = 16.7] | |--[dendrogram w/ 2 branches and 8 members at h = 6.82] | | |--[dendrogram w/ 2 branches and 3 members at h = 2.13] | | | |--leaf "14" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1.2] | | | |--leaf "2" | | | `--leaf "11" | | `--[dendrogram w/ 2 branches and 5 members at h = 2.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.3] | | | |--leaf "1" | | | `--leaf "12" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.5] | | |--leaf "26" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | | |--leaf "5" | | `--leaf "37" | `--[dendrogram w/ 2 branches and 7 members at h = 8.21] | |--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | |--leaf "3" | | `--leaf "40" | `--[dendrogram w/ 2 branches and 5 members at h = 1.29] | |--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | |--leaf "29" | | `--leaf "55" | `--[dendrogram w/ 2 branches and 3 members at h = 0.133] | |--leaf "38" | `--[dendrogram w/ 2 branches and 2 members at h = 0] | |--leaf "17" | `--leaf "44" `--[dendrogram w/ 2 branches and 28 members at h = 149] |--[dendrogram w/ 2 branches and 19 members at h = 33.0] | |--[dendrogram w/ 2 branches and 7 members at h = 8.31] | | |--[dendrogram w/ 2 branches and 4 members at h = 2.5] | | | |--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | | | |--leaf "39" | | | | `--leaf "60" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.8] | | | |--leaf "10" | | | `--leaf "18" | | `--[dendrogram w/ 2 branches and 3 members at h = 3.73] | | |--leaf "45" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "30" | | `--leaf "52" | `--[dendrogram w/ 2 branches and 12 members at h = 13.7] | |--[dendrogram w/ 2 branches and 4 members at h = 1.97] | | |--leaf "6" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.133] | | |--leaf "35" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "9" | | `--leaf "33" | `--[dendrogram w/ 2 branches and 8 members at h = 5.66] | |--[dendrogram w/ 2 branches and 3 members at h = 0.733] | | |--leaf "15" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | |--leaf "22" | | `--leaf "56" | `--[dendrogram w/ 2 branches and 5 members at h = 2.06] | |--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | |--leaf "49" | | `--leaf "50" | `--[dendrogram w/ 2 branches and 3 members at h = 0.4] | |--leaf "21" | `--[dendrogram w/ 2 branches and 2 members at h = 0] | |--leaf "41" | `--leaf "48" `--[dendrogram w/ 2 branches and 9 members at h = 47.4] |--[dendrogram w/ 2 branches and 2 members at h = 5.5] | |--leaf "54" | `--leaf "58" `--[dendrogram w/ 2 branches and 7 members at h = 13.2] |--[dendrogram w/ 2 branches and 3 members at h = 2.3] | |--leaf "42" | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | |--leaf "47" | `--leaf "53" `--[dendrogram w/ 2 branches and 4 members at h = 4.48] |--leaf "57" `--[dendrogram w/ 2 branches and 3 members at h = 1.87] |--leaf "46" `--[dendrogram w/ 2 branches and 2 members at h = 0.8] |--leaf "51" `--leaf "59" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/174rj1226413648.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/20ink1226413648.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/3u7x01226413648.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/422oy1226413648.tab") + } > > system("convert tmp/174rj1226413648.ps tmp/174rj1226413648.png") > system("convert tmp/20ink1226413648.ps tmp/20ink1226413648.png") convert: unable to open image `tmp/20ink1226413648.ps': No such file or directory. convert: missing an image filename `tmp/20ink1226413648.png'. > > > proc.time() user system elapsed 0.794 0.186 1.404