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(4.56,4.51,4.77,5.25,4.41,4.38,4.75,5.25,4.33,4.29,4.91,5.18,4.2,4.08,4.68,5,4.25,4.2,4.71,5,4.25,4.22,4.61,5,4.19,4.15,4.36,5,4.17,4.12,4.3,5,4.21,4.18,4.54,5,4.21,4.19,4.71,5,4.17,4.15,4.57,5,4.16,4.13,4.63,5,4.19,4.17,4.57,5,4.08,4.07,4.33,5,4.06,4.05,4.14,5,3.98,3.97,4.08,4.9,3.82,3.82,3.98,4.75,3.82,3.82,3.89,4.75,3.72,3.72,3.82,4.65,3.56,3.55,3.74,4.5,3.57,3.56,3.67,4.5,3.49,3.47,3.61,4.39,3.32,3.31,3.51,4.25,3.23,3.22,3.36,4.17),dim=c(4,24),dimnames=list(c('X1','X2','X3','X4'),1:24)) > y <- array(NA,dim=c(4,24),dimnames=list(c('X1','X2','X3','X4'),1:24)) > 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 24 members at h = 8.41] |--[dendrogram w/ 2 branches and 5 members at h = 0.981] | |--[dendrogram w/ 2 branches and 2 members at h = 0.212] | | |--leaf "23" | | `--leaf "24" | `--[dendrogram w/ 2 branches and 3 members at h = 0.226] | |--leaf "22" | `--[dendrogram w/ 2 branches and 2 members at h = 0.0714] | |--leaf "20" | `--leaf "21" `--[dendrogram w/ 2 branches and 19 members at h = 3.91] |--[dendrogram w/ 2 branches and 11 members at h = 1.41] | |--[dendrogram w/ 2 branches and 8 members at h = 0.285] | | |--[dendrogram w/ 2 branches and 4 members at h = 0.125] | | | |--leaf "6" | | | `--[dendrogram w/ 2 branches and 3 members at h = 0.0544] | | | |--leaf "9" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.0283] | | | |--leaf "11" | | | `--leaf "13" | | `--[dendrogram w/ 2 branches and 4 members at h = 0.188] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.0412] | | | |--leaf "5" | | | `--leaf "10" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.0812] | | |--leaf "4" | | `--leaf "12" | `--[dendrogram w/ 2 branches and 3 members at h = 0.311] | |--leaf "3" | `--[dendrogram w/ 2 branches and 2 members at h = 0.199] | |--leaf "1" | `--leaf "2" `--[dendrogram w/ 2 branches and 8 members at h = 1.74] |--[dendrogram w/ 2 branches and 3 members at h = 0.252] | |--leaf "19" | `--[dendrogram w/ 2 branches and 2 members at h = 0.09] | |--leaf "17" | `--leaf "18" `--[dendrogram w/ 2 branches and 5 members at h = 0.508] |--[dendrogram w/ 2 branches and 3 members at h = 0.141] | |--leaf "14" | `--[dendrogram w/ 2 branches and 2 members at h = 0.07] | |--leaf "7" | `--leaf "8" `--[dendrogram w/ 2 branches and 2 members at h = 0.162] |--leaf "15" `--leaf "16" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1mjyu1226619158.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/2nsne1226619158.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/33kag1226619158.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/4t3wc1226619158.tab") + } > > system("convert tmp/1mjyu1226619158.ps tmp/1mjyu1226619158.png") > system("convert tmp/2nsne1226619158.ps tmp/2nsne1226619158.png") convert: unable to open image `tmp/2nsne1226619158.ps': No such file or directory. convert: missing an image filename `tmp/2nsne1226619158.png'. > > > proc.time() user system elapsed 0.670 0.211 1.614