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(-13,-7,-3,-32,18,-7,-36,9,15,-22,-8,-19,2,-5,6,-10,6,2,-21,13,-16,-1,0,-14,-20,9,14,0,8,-5,19,-4,-12,-14,12,8,-49,1,18,-30,15,12,-14,13,-3,-12,-17,4,5,-3,8,0,15,-25,-14,16,20,-4,-21,12,-11,5,3,-9,-4,18,-6,-4,3,-13,-2,19,-29,-12,13,-31,-8,25,-37,-9,16,-33,-15,-5,-26,-15,12,-21,-5,18,-27,-31,-16,-29,-23,-21,-31,-25,-16,-13,-40,-8,4,-33,-25,-18,-26,-24,-21,-43,0),dim=c(3,37),dimnames=list(c('Kleding','Hout','Papier'),1:37)) > y <- array(NA,dim=c(3,37),dimnames=list(c('Kleding','Hout','Papier'),1:37)) > 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 37 members at h = 259] |--[dendrogram w/ 2 branches and 9 members at h = 61.8] | |--[dendrogram w/ 2 branches and 6 members at h = 29.9] | | |--[dendrogram w/ 2 branches and 4 members at h = 16.3] | | | |--leaf "36" | | | `--[dendrogram w/ 2 branches and 3 members at h = 9.32] | | | |--leaf "31" | | | `--[dendrogram w/ 2 branches and 2 members at h = 5.74] | | | |--leaf "32" | | | `--leaf "33" | | `--[dendrogram w/ 2 branches and 2 members at h = 19.1] | | |--leaf "4" | | `--leaf "28" | `--[dendrogram w/ 2 branches and 3 members at h = 37.3] | |--leaf "35" | `--[dendrogram w/ 2 branches and 2 members at h = 11.7] | |--leaf "34" | `--leaf "37" `--[dendrogram w/ 2 branches and 28 members at h = 162] |--[dendrogram w/ 2 branches and 10 members at h = 58.3] | |--[dendrogram w/ 2 branches and 3 members at h = 23.6] | | |--leaf "13" | | `--[dendrogram w/ 2 branches and 2 members at h = 9] | | |--leaf "3" | | `--leaf "14" | `--[dendrogram w/ 2 branches and 7 members at h = 43.0] | |--[dendrogram w/ 2 branches and 3 members at h = 12.2] | | |--leaf "30" | | `--[dendrogram w/ 2 branches and 2 members at h = 4.58] | | |--leaf "22" | | `--leaf "24" | `--[dendrogram w/ 2 branches and 4 members at h = 17.7] | |--[dendrogram w/ 2 branches and 2 members at h = 4.36] | | |--leaf "25" | | `--leaf "29" | `--[dendrogram w/ 2 branches and 2 members at h = 10.9] | |--leaf "26" | `--leaf "27" `--[dendrogram w/ 2 branches and 18 members at h = 98.4] |--[dendrogram w/ 2 branches and 8 members at h = 49] | |--[dendrogram w/ 2 branches and 2 members at h = 15.1] | | |--leaf "2" | | `--leaf "7" | `--[dendrogram w/ 2 branches and 6 members at h = 29.7] | |--[dendrogram w/ 2 branches and 3 members at h = 12.7] | | |--leaf "15" | | `--[dendrogram w/ 2 branches and 2 members at h = 1.73] | | |--leaf "6" | | `--leaf "21" | `--[dendrogram w/ 2 branches and 3 members at h = 12.8] | |--leaf "19" | `--[dendrogram w/ 2 branches and 2 members at h = 9] | |--leaf "9" | `--leaf "12" `--[dendrogram w/ 2 branches and 10 members at h = 71] |--[dendrogram w/ 2 branches and 4 members at h = 28.3] | |--leaf "11" | `--[dendrogram w/ 2 branches and 3 members at h = 22.5] | |--leaf "18" | `--[dendrogram w/ 2 branches and 2 members at h = 12.1] | |--leaf "8" | `--leaf "10" `--[dendrogram w/ 2 branches and 6 members at h = 29.0] |--[dendrogram w/ 2 branches and 2 members at h = 12] | |--leaf "16" | `--leaf "20" `--[dendrogram w/ 2 branches and 4 members at h = 23] |--[dendrogram w/ 2 branches and 2 members at h = 4.12] | |--leaf "5" | `--leaf "17" `--[dendrogram w/ 2 branches and 2 members at h = 9.7] |--leaf "1" `--leaf "23" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1cwvv1226413072.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/26zok1226413072.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/3syui1226413072.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/4ftxh1226413072.tab") + } > > system("convert tmp/1cwvv1226413072.ps tmp/1cwvv1226413072.png") > system("convert tmp/26zok1226413072.ps tmp/26zok1226413072.png") convert: unable to open image `tmp/26zok1226413072.ps': No such file or directory. convert: missing an image filename `tmp/26zok1226413072.png'. > > > proc.time() user system elapsed 0.707 0.216 0.824