R version 2.8.0 (2008-10-20) 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(7.8 + ,9.0 + ,21.1 + ,7.0 + ,7.6 + ,9.1 + ,21.0 + ,6.9 + ,7.5 + ,8.7 + ,20.4 + ,6.7 + ,7.6 + ,8.2 + ,19.5 + ,6.6 + ,7.5 + ,7.9 + ,18.6 + ,6.5 + ,7.3 + ,7.9 + ,18.8 + ,6.4 + ,7.6 + ,9.1 + ,23.7 + ,6.5 + ,7.5 + ,9.4 + ,24.8 + ,6.5 + ,7.6 + ,9.5 + ,25.0 + ,6.6 + ,7.9 + ,9.1 + ,23.6 + ,6.7 + ,7.9 + ,9.0 + ,22.3 + ,6.8 + ,8.1 + ,9.3 + ,21.8 + ,7.2 + ,8.2 + ,9.9 + ,20.8 + ,7.6 + ,8.0 + ,9.8 + ,19.7 + ,7.6 + ,7.5 + ,9.4 + ,18.3 + ,7.3 + ,6.8 + ,8.3 + ,17.4 + ,6.4 + ,6.5 + ,8.0 + ,17.0 + ,6.1 + ,6.6 + ,8.5 + ,18.1 + ,6.3 + ,7.6 + ,10.4 + ,23.9 + ,7.1 + ,8.0 + ,11.1 + ,25.6 + ,7.5 + ,8.0 + ,10.9 + ,25.3 + ,7.4 + ,7.7 + ,9.9 + ,23.6 + ,7.1 + ,7.5 + ,9.2 + ,21.9 + ,6.8 + ,7.6 + ,9.2 + ,21.4 + ,6.9 + ,7.7 + ,9.5 + ,20.6 + ,7.2 + ,7.9 + ,9.6 + ,20.5 + ,7.4 + ,7.8 + ,9.5 + ,20.2 + ,7.3 + ,7.5 + ,9.1 + ,20.6 + ,6.9 + ,7.5 + ,8.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+ ,5.9 + ,6.7 + ,14.1 + ,5.5 + ,6.4 + ,7.3 + ,17.3 + ,5.7 + ,6.4 + ,7.5 + ,18.1 + ,5.8) + ,dim=c(4 + ,68) + ,dimnames=list(c('mannen' + ,'vrouwen' + ,'onder25j' + ,'boven25j') + ,1:68)) > y <- array(NA,dim=c(4,68),dimnames=list(c('mannen','vrouwen','onder25j','boven25j'),1:68)) > 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 68 members at h = 67.7] |--[dendrogram w/ 2 branches and 19 members at h = 15.4] | |--[dendrogram w/ 2 branches and 4 members at h = 2.94] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.412] | | | |--leaf "65" | | | `--leaf "66" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.458] | | |--leaf "63" | | `--leaf "64" | `--[dendrogram w/ 2 branches and 15 members at h = 6.88] | |--[dendrogram w/ 2 branches and 7 members at h = 1.24] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.9] | | | |--leaf "62" | | | `--leaf "67" | | `--[dendrogram w/ 2 branches and 5 members at h = 1.08] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.424] | | | |--leaf "16" | | | `--leaf "61" | | `--[dendrogram w/ 2 branches and 3 members at h = 0.507] | | |--leaf "59" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.1] | | |--leaf "17" | | `--leaf "60" | `--[dendrogram w/ 2 branches and 8 members at h = 3.20] | |--[dendrogram w/ 2 branches and 3 members at h = 1.10] | | |--leaf "4" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | | |--leaf "5" | | `--leaf "6" | `--[dendrogram w/ 2 branches and 5 members at h = 1.67] | |--leaf "57" | `--[dendrogram w/ 2 branches and 4 members at h = 1.26] | |--[dendrogram w/ 2 branches and 2 members at h = 0.424] | | |--leaf "58" | | `--leaf "68" | `--[dendrogram w/ 2 branches and 2 members at h = 0.529] | |--leaf "18" | `--leaf "54" `--[dendrogram w/ 2 branches and 49 members at h = 43.2] |--[dendrogram w/ 2 branches and 12 members at h = 5.6] | |--[dendrogram w/ 2 branches and 2 members at h = 0.374] | | |--leaf "20" | | `--leaf "21" | `--[dendrogram w/ 2 branches and 10 members at h = 3.64] | |--[dendrogram w/ 2 branches and 4 members at h = 2.34] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.265] | | | |--leaf "8" | | | `--leaf "9" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.374] | | |--leaf "7" | | `--leaf "10" | `--[dendrogram w/ 2 branches and 6 members at h = 2.71] | |--[dendrogram w/ 2 branches and 2 members at h = 0.332] | | |--leaf "44" | | `--leaf "45" | `--[dendrogram w/ 2 branches and 4 members at h = 0.55] | |--leaf "22" | `--[dendrogram w/ 2 branches and 3 members at h = 0.447] | |--leaf "32" | `--[dendrogram w/ 2 branches and 2 members at h = 0.224] | |--leaf "19" | `--leaf "33" `--[dendrogram w/ 2 branches and 37 members at h = 19.9] |--[dendrogram w/ 2 branches and 16 members at h = 5.83] | |--[dendrogram w/ 2 branches and 9 members at h = 2.23] | | |--[dendrogram w/ 2 branches and 5 members at h = 0.923] | | | |--[dendrogram w/ 2 branches and 2 members at h = 0.3] | | | | |--leaf "12" | | | | `--leaf "36" | | | `--[dendrogram w/ 2 branches and 3 members at h = 0.601] | | | |--leaf "11" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.245] | | | |--leaf "23" | | | `--leaf "35" | | `--[dendrogram w/ 2 branches and 4 members at h = 1.93] | | |--[dendrogram w/ 2 branches and 2 members at h = 0.583] | | | |--leaf "31" | | | `--leaf "34" | | `--[dendrogram w/ 2 branches and 2 members at h = 1.05] | | |--leaf "43" | | `--leaf "46" | `--[dendrogram w/ 2 branches and 7 members at h = 3.45] | |--[dendrogram w/ 2 branches and 2 members at h = 0.51] | | |--leaf "55" | | `--leaf "56" | `--[dendrogram w/ 2 branches and 5 members at h = 1.25] | |--[dendrogram w/ 2 branches and 3 members at h = 0.470] | | |--leaf "24" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.265] | | |--leaf "1" | | `--leaf "2" | `--[dendrogram w/ 2 branches and 2 members at h = 0.49] | |--leaf "3" | `--leaf "28" `--[dendrogram w/ 2 branches and 21 members at h = 9.7] |--[dendrogram w/ 2 branches and 9 members at h = 2.89] | |--[dendrogram w/ 2 branches and 6 members at h = 0.875] | | |--leaf "13" | | `--[dendrogram w/ 2 branches and 5 members at h = 0.625] | | |--[dendrogram w/ 2 branches and 3 members at h = 0.408] | | | |--leaf "27" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0.316] | | | |--leaf "25" | | | `--leaf "26" | | `--[dendrogram w/ 2 branches and 2 members at h = 0.52] | | |--leaf "37" | | `--leaf "38" | `--[dendrogram w/ 2 branches and 3 members at h = 0.998] | |--leaf "14" | `--[dendrogram w/ 2 branches and 2 members at h = 0.469] | |--leaf "39" | `--leaf "40" `--[dendrogram w/ 2 branches and 12 members at h = 4.07] |--[dendrogram w/ 2 branches and 5 members at h = 1.15] | |--[dendrogram w/ 2 branches and 2 members at h = 0.48] | | |--leaf "30" | | `--leaf "53" | `--[dendrogram w/ 2 branches and 3 members at h = 0.759] | |--leaf "29" | `--[dendrogram w/ 2 branches and 2 members at h = 0.3] | |--leaf "47" | `--leaf "52" `--[dendrogram w/ 2 branches and 7 members at h = 1.44] |--[dendrogram w/ 2 branches and 2 members at h = 0.693] | |--leaf "15" | `--leaf "41" `--[dendrogram w/ 2 branches and 5 members at h = 0.764] |--[dendrogram w/ 2 branches and 2 members at h = 0.245] | |--leaf "50" | `--leaf "51" `--[dendrogram w/ 2 branches and 3 members at h = 0.343] |--leaf "42" `--[dendrogram w/ 2 branches and 2 members at h = 0.265] |--leaf "48" `--leaf "49" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/freestat/rcomp/tmp/11uhs1226431568.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/2x0eo1226431568.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/3xsxy1226431568.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/4lvbl1226431568.tab") + } > > system("convert tmp/11uhs1226431568.ps tmp/11uhs1226431568.png") > system("convert tmp/2x0eo1226431568.ps tmp/2x0eo1226431568.png") convert: unable to open image `tmp/2x0eo1226431568.ps': No such file or directory. convert: missing an image filename `tmp/2x0eo1226431568.png'. > > > proc.time() user system elapsed 0.845 0.265 0.911