R version 2.6.1 (2007-11-26) Copyright (C) 2007 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(281,0.88,295,0.87,294,0.88,302,0.89,314,0.92,321,0.96,313,0.99,310,0.98,319,0.98,316,0.98,319,1.00,333,1.02,356,1.06,358,1.08,340,1.08,328,1.08,355,1.16,356,1.17,351,1.14,359,1.11,378,1.12,378,1.17,389.,1.17,407,1.23,413,1.26,404,1.26,406,1.23,402,1.20,383,1.20,392,1.21,398,1.23,400,1.22,405,1.22,420,1.25,439,1.30,441,1.34,424,1.31,423,1.30,434,1.32,429,1.29,421,1.27,430,1.22,424,1.20,437,1.23,456,1.23,469,1.20,476,1.18,510,1.19,549,1.21,554,1.19,557,1.20,610,1.23,675,1.28,596,1.27,633,1.27,632,1.28,596,1.27,585,1.26,627,1.29,629,1.32),dim=c(2,60),dimnames=list(c('Goud','Dollar'),1:60)) > y <- array(NA,dim=c(2,60),dimnames=list(c('Goud','Dollar'),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 = 3279] |--[dendrogram w/ 2 branches and 12 members at h = 237] | |--[dendrogram w/ 2 branches and 5 members at h = 69.5] | | |--leaf "53" | | `--[dendrogram w/ 2 branches and 4 members at h = 7.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "55" | | | `--leaf "56" | | `--[dendrogram w/ 2 branches and 2 members at h = 2] | | |--leaf "59" | | `--leaf "60" | `--[dendrogram w/ 2 branches and 7 members at h = 127] | |--[dendrogram w/ 2 branches and 3 members at h = 7.67] | | |--leaf "49" | | `--[dendrogram w/ 2 branches and 2 members at h = 3] | | |--leaf "50" | | `--leaf "51" | `--[dendrogram w/ 2 branches and 4 members at h = 22.8] | |--leaf "52" | `--[dendrogram w/ 2 branches and 3 members at h = 14.7] | |--leaf "58" | `--[dendrogram w/ 2 branches and 2 members at h = 0] | |--leaf "54" | `--leaf "57" `--[dendrogram w/ 2 branches and 48 members at h = 1331] |--[dendrogram w/ 2 branches and 14 members at h = 111] | |--[dendrogram w/ 2 branches and 4 members at h = 21.3] | | |--leaf "1" | | `--[dendrogram w/ 2 branches and 3 members at h = 9.67] | | |--leaf "4" | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "2" | | `--leaf "3" | `--[dendrogram w/ 2 branches and 10 members at h = 54.4] | |--[dendrogram w/ 2 branches and 3 members at h = 11] | | |--leaf "15" | | `--[dendrogram w/ 2 branches and 2 members at h = 5] | | |--leaf "12" | | `--leaf "16" | `--[dendrogram w/ 2 branches and 7 members at h = 16.4] | |--[dendrogram w/ 2 branches and 3 members at h = 2.66] | | |--leaf "6" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.02] | | |--leaf "9" | | `--leaf "11" | `--[dendrogram w/ 2 branches and 4 members at h = 5.5] | |--leaf "8" | `--[dendrogram w/ 2 branches and 3 members at h = 3] | |--leaf "10" | `--[dendrogram w/ 2 branches and 2 members at h = 1.00] | |--leaf "5" | `--leaf "7" `--[dendrogram w/ 2 branches and 34 members at h = 575] |--[dendrogram w/ 2 branches and 15 members at h = 199] | |--[dendrogram w/ 2 branches and 11 members at h = 50.7] | | |--[dendrogram w/ 2 branches and 4 members at h = 6.5] | | | |--[dendrogram w/ 2 branches and 2 members at h = 2] | | | | |--leaf "35" | | | | `--leaf "36" | | | `--[dendrogram w/ 2 branches and 2 members at h = 3] | | | |--leaf "39" | | | `--leaf "44" | | `--[dendrogram w/ 2 branches and 7 members at h = 17.0] | | |--[dendrogram w/ 2 branches and 2 members at h = 1.00] | | | |--leaf "40" | | | `--leaf "42" | | `--[dendrogram w/ 2 branches and 5 members at h = 6.44] | | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "34" | | | `--leaf "41" | | `--[dendrogram w/ 2 branches and 3 members at h = 1.3] | | |--leaf "38" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.11] | | |--leaf "37" | | `--leaf "43" | `--[dendrogram w/ 2 branches and 4 members at h = 57.8] | |--leaf "48" | `--[dendrogram w/ 2 branches and 3 members at h = 19.7] | |--leaf "45" | `--[dendrogram w/ 2 branches and 2 members at h = 7] | |--leaf "46" | `--leaf "47" `--[dendrogram w/ 2 branches and 19 members at h = 272] |--[dendrogram w/ 2 branches and 6 members at h = 8.33] | |--leaf "19" | `--[dendrogram w/ 2 branches and 5 members at h = 5.64] | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "14" | | `--leaf "20" | `--[dendrogram w/ 2 branches and 3 members at h = 1.3] | |--leaf "17" | `--[dendrogram w/ 2 branches and 2 members at h = 0.11] | |--leaf "13" | `--leaf "18" `--[dendrogram w/ 2 branches and 13 members at h = 91.5] |--[dendrogram w/ 2 branches and 8 members at h = 16.9] | |--[dendrogram w/ 2 branches and 3 members at h = 3.33] | | |--leaf "28" | | `--[dendrogram w/ 2 branches and 2 members at h = 2] | | |--leaf "31" | | `--leaf "32" | `--[dendrogram w/ 2 branches and 5 members at h = 11] | |--leaf "25" | `--[dendrogram w/ 2 branches and 4 members at h = 3] | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "24" | | `--leaf "27" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "26" | `--leaf "33" `--[dendrogram w/ 2 branches and 5 members at h = 21.5] |--[dendrogram w/ 2 branches and 2 members at h = 3] | |--leaf "23" | `--leaf "30" `--[dendrogram w/ 2 branches and 3 members at h = 6.65] |--leaf "29" `--[dendrogram w/ 2 branches and 2 members at h = 0.05] |--leaf "21" `--leaf "22" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1eekj1200488830.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/24c8x1200488830.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) + } > 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/373k01200488830.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/4zkoa1200488830.tab") + } > > system("convert tmp/1eekj1200488830.ps tmp/1eekj1200488830.png") > system("convert tmp/24c8x1200488830.ps tmp/24c8x1200488830.png") convert: unable to open image `tmp/24c8x1200488830.ps': No such file or directory. convert: missing an image filename `tmp/24c8x1200488830.png'. > > > proc.time() user system elapsed 0.809 0.212 0.901