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(113.5,121.2,130.4,115.2,117.9,110.7,107.6,124.3,115.1,112.5,127.9,117.4,119.3,130.4,126,125.4,130.5,115.9,108.7,124,119.4,118.6,131.3,111.1,124.8,132.3,126.7,131.7,130.9,122.1,113.2,133.6,119.2,129.4,131.4,117.1,130.5,132.3,140.8,137.5,128.6,126.7,120.8,139.3,128.6,131.3,136.3,128.8,133.2,136.3,151.1,145,134.4,135.7,128.7,129.2,138.6,132.7,132.5,135.2),dim=c(1,60),dimnames=list(c('Voeding'),1:60)) > y <- array(NA,dim=c(1,60),dimnames=list(c('Voeding'),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 = 294] |--[dendrogram w/ 2 branches and 20 members at h = 45.6] | |--[dendrogram w/ 2 branches and 10 members at h = 9.13] | | |--[dendrogram w/ 2 branches and 3 members at h = 1.33] | | | |--leaf "30" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.4] | | | |--leaf "2" | | | `--leaf "43" | | `--[dendrogram w/ 2 branches and 7 members at h = 4.09] | | |--[dendrogram w/ 2 branches and 3 members at h = 0.167] | | | |--leaf "21" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | | |--leaf "13" | | | `--leaf "33" | | `--[dendrogram w/ 2 branches and 4 members at h = 1.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.3] | | | |--leaf "12" | | | `--leaf "36" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.7] | | |--leaf "5" | | `--leaf "22" | `--[dendrogram w/ 2 branches and 10 members at h = 12.7] | |--[dendrogram w/ 2 branches and 2 members at h = 1.1] | | |--leaf "7" | | `--leaf "19" | `--[dendrogram w/ 2 branches and 8 members at h = 9.02] | |--[dendrogram w/ 2 branches and 3 members at h = 0.967] | | |--leaf "18" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | |--leaf "4" | | `--leaf "9" | `--[dendrogram w/ 2 branches and 5 members at h = 4.43] | |--[dendrogram w/ 2 branches and 2 members at h = 0.4] | | |--leaf "6" | | `--leaf "24" | `--[dendrogram w/ 2 branches and 3 members at h = 1.03] | |--leaf "10" | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | |--leaf "1" | `--leaf "31" `--[dendrogram w/ 2 branches and 40 members at h = 89.3] |--[dendrogram w/ 2 branches and 10 members at h = 25.7] | |--[dendrogram w/ 2 branches and 2 members at h = 6.1] | | |--leaf "51" | | `--leaf "52" | `--[dendrogram w/ 2 branches and 8 members at h = 9.07] | |--[dendrogram w/ 2 branches and 4 members at h = 1.45] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "47" | | | `--leaf "50" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.5] | | |--leaf "54" | | `--leaf "60" | `--[dendrogram w/ 2 branches and 4 members at h = 2.9] | |--leaf "39" | `--[dendrogram w/ 2 branches and 3 members at h = 1.7] | |--leaf "40" | `--[dendrogram w/ 2 branches and 2 members at h = 0.7] | |--leaf "44" | `--leaf "57" `--[dendrogram w/ 2 branches and 30 members at h = 45.6] |--[dendrogram w/ 2 branches and 16 members at h = 11.1] | |--[dendrogram w/ 2 branches and 9 members at h = 3.18] | | |--[dendrogram w/ 2 branches and 4 members at h = 0.517] | | | |--leaf "28" | | | `--[dendrogram w/ 2 branches and 3 members at h = 0.133] | | | |--leaf "35" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "23" | | | `--leaf "46" | | `--[dendrogram w/ 2 branches and 5 members at h = 0.68] | | |--leaf "29" | | `--[dendrogram w/ 2 branches and 4 members at h = 0.2] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "3" | | | `--leaf "14" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "17" | | `--leaf "37" | `--[dendrogram w/ 2 branches and 7 members at h = 3.19] | |--[dendrogram w/ 2 branches and 4 members at h = 0.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "26" | | | `--leaf "38" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | |--leaf "58" | | `--leaf "59" | `--[dendrogram w/ 2 branches and 3 members at h = 1.2] | |--leaf "53" | `--[dendrogram w/ 2 branches and 2 members at h = 0.4] | |--leaf "32" | `--leaf "49" `--[dendrogram w/ 2 branches and 14 members at h = 17.6] |--[dendrogram w/ 2 branches and 7 members at h = 1.65] | |--[dendrogram w/ 2 branches and 2 members at h = 0.2] | | |--leaf "34" | | `--leaf "56" | `--[dendrogram w/ 2 branches and 5 members at h = 1.17] | |--leaf "11" | `--[dendrogram w/ 2 branches and 4 members at h = 0.25] | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "41" | | `--leaf "45" | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | |--leaf "48" | `--leaf "55" `--[dendrogram w/ 2 branches and 7 members at h = 4.69] |--[dendrogram w/ 2 branches and 3 members at h = 0.767] | |--leaf "25" | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | |--leaf "8" | `--leaf "20" `--[dendrogram w/ 2 branches and 4 members at h = 1.7] |--[dendrogram w/ 2 branches and 2 members at h = 0] | |--leaf "27" | `--leaf "42" `--[dendrogram w/ 2 branches and 2 members at h = 0.6] |--leaf "15" `--leaf "16" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/freestat/rcomp/tmp/1g8jq1226069434.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/2icse1226069434.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/3nt5j1226069434.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/40ebs1226069434.tab") + } > > system("convert tmp/1g8jq1226069434.ps tmp/1g8jq1226069434.png") > system("convert tmp/2icse1226069434.ps tmp/2icse1226069434.png") convert: unable to open image `tmp/2icse1226069434.ps': No such file or directory. convert: missing an image filename `tmp/2icse1226069434.png'. > > > proc.time() user system elapsed 1.108 0.254 1.203