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(82.7 + ,97.4 + ,74.8 + ,89.3 + ,88.9 + ,97 + ,93.1 + ,87.5 + ,105.9 + ,105.4 + ,103.9 + ,106.7 + ,100.8 + ,102.7 + ,83.9 + ,102.5 + ,94 + ,98.1 + ,77.7 + ,109.2 + ,105 + ,104.5 + ,141.5 + ,123.7 + ,58.5 + ,87.4 + ,58.9 + ,83.1 + ,87.6 + ,89.9 + ,75.3 + ,97 + ,113.1 + ,109.8 + ,108.4 + ,119.1 + ,112.5 + ,111.7 + ,91 + ,125.1 + ,89.6 + ,98.6 + ,84.6 + ,113.6 + ,74.5 + ,96.9 + ,179.8 + ,122.4 + ,82.7 + ,95.1 + ,85.6 + ,92.8 + ,90.1 + ,97 + ,76.4 + ,97.2 + ,109.4 + ,112.7 + ,109.7 + ,115.6 + ,96 + ,102.9 + ,99.1 + ,111.3 + ,89.2 + ,97.4 + ,86.7 + ,114.6 + ,109.1 + ,111.4 + ,111.4 + ,137.5 + ,49.1 + ,87.4 + ,78.4 + ,83.7 + ,92.9 + ,96.8 + ,76.7 + ,106 + ,107.7 + ,114.1 + ,114.2 + ,123.4 + ,103.5 + ,110.3 + ,99.7 + ,126.5 + ,91.1 + ,103.9 + ,94.2 + ,120 + ,79.8 + ,101.6 + ,173.5 + ,141.6 + ,71.9 + ,94.6 + ,83.1 + ,90.5 + ,82.9 + ,95.9 + ,88.9 + ,96.5 + ,90.1 + ,104.7 + ,132 + ,113.5 + ,100.7 + ,102.8 + ,122.1 + ,120.1 + ,90.7 + ,98.1 + ,105.1 + ,123.9 + ,108.8 + ,113.9 + ,133.7 + ,144.4 + ,44.1 + ,80.9 + ,63.6 + ,90.8 + ,93.6 + ,95.7 + ,112.7 + ,114.2 + ,107.4 + ,113.2 + ,120.5 + ,138.1 + ,96.5 + ,105.9 + ,112 + ,135 + ,93.6 + ,108.8 + ,126.2 + ,131.3 + ,76.5 + ,102.3 + ,209.2 + ,144.6 + ,76.7 + ,99 + ,91 + ,101.7 + ,84 + ,100.7 + ,116.7 + ,108.7 + ,103.3 + ,115.5 + ,137.6 + ,135.3 + ,88.5 + ,100.7 + ,108.1 + ,124.3 + ,99 + ,109.9 + ,136.6 + ,138.3 + ,105.9 + ,114.6 + ,152.3 + ,158.2 + ,44.7 + ,85.4 + ,114.3 + ,93.5 + ,94 + ,100.5 + ,120.7 + ,124.8 + ,107.1 + ,114.8 + ,131.8 + ,154.4 + ,104.8 + ,116.5 + ,129.4 + ,152.8 + ,102.5 + ,112.9 + ,187.5 + ,148.9 + ,77.7 + ,102 + ,189.5 + ,170.3 + ,85.2 + ,106 + ,109.2 + ,124.8 + ,91.3 + ,105.3 + ,158.1 + ,134.4 + ,106.5 + ,118.8 + ,176.2 + ,154 + ,92.4 + ,106.1 + ,125.5 + ,147.9 + ,97.5 + ,109.3 + ,155 + ,168.1 + ,107 + ,117.2 + ,170.3 + ,175.7 + ,51.1 + ,92.5 + ,99.4 + ,116.7 + ,98.6 + ,104.2 + ,139.2 + ,140.8 + ,102.2 + ,112.5 + ,169.6 + ,164.2 + ,114.3 + ,122.4 + ,136.1 + ,173.8 + ,99.4 + ,113.3 + ,168.2 + ,167.8 + ,72.5 + ,100 + ,318.6 + ,166.6 + ,92.3 + ,110.7 + ,154.1 + ,135.1 + ,99.4 + ,112.8 + ,161.4 + ,158.1 + ,85.9 + ,109.8 + ,183.4 + ,151.8 + ,109.4 + ,117.3 + ,167.2 + ,168.7 + ,97.6 + ,109.1 + ,205.3 + ,166.9) + ,dim=c(4 + ,65) + ,dimnames=list(c('x1' + ,'x2' + ,'x3' + ,'x4') + ,1:65)) > y <- array(NA,dim=c(4,65),dimnames=list(c('x1','x2','x3','x4'),1:65)) > 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 = '10' > par1 = 'average' > 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 65 members at h = 202] |--leaf "60" `--[dendrogram w/ 2 branches and 64 members at h = 86.2] |--[dendrogram w/ 2 branches and 16 members at h = 45.6] | |--[dendrogram w/ 2 branches and 10 members at h = 37.4] | | |--leaf "58" | | `--[dendrogram w/ 2 branches and 9 members at h = 25.7] | | |--[dendrogram w/ 2 branches and 2 members at h = 14.3] | | | |--leaf "47" | | | `--leaf "51" | | `--[dendrogram w/ 2 branches and 7 members at h = 17.6] | | |--[dendrogram w/ 2 branches and 5 members at h = 14] | | | |--[dendrogram w/ 2 branches and 2 members at h = 8.02] | | | | |--leaf "54" | | | | `--leaf "64" | | | `--[dendrogram w/ 2 branches and 3 members at h = 11.2] | | | |--leaf "62" | | | `--[dendrogram w/ 2 branches and 2 members at h = 4.84] | | | |--leaf "57" | | | `--leaf "59" | | `--[dendrogram w/ 2 branches and 2 members at h = 14.3] | | |--leaf "42" | | `--leaf "53" | `--[dendrogram w/ 2 branches and 6 members at h = 37.7] | |--[dendrogram w/ 2 branches and 3 members at h = 27.8] | | |--leaf "12" | | `--[dendrogram w/ 2 branches and 2 members at h = 17.5] | | |--leaf "24" | | `--leaf "63" | `--[dendrogram w/ 2 branches and 3 members at h = 32.0] | |--leaf "36" | `--[dendrogram w/ 2 branches and 2 members at h = 26.6] | |--leaf "48" | `--leaf "65" `--[dendrogram w/ 2 branches and 48 members at h = 60.3] |--[dendrogram w/ 2 branches and 30 members at h = 39.2] | |--[dendrogram w/ 2 branches and 20 members at h = 26.3] | | |--[dendrogram w/ 2 branches and 7 members at h = 23.5] | | | |--[dendrogram w/ 2 branches and 3 members at h = 15.0] | | | | |--leaf "34" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 9.45] | | | | |--leaf "18" | | | | `--leaf "33" | | | `--[dendrogram w/ 2 branches and 4 members at h = 17.5] | | | |--leaf "27" | | | `--[dendrogram w/ 2 branches and 3 members at h = 13.5] | | | |--leaf "35" | | | `--[dendrogram w/ 2 branches and 2 members at h = 8.62] | | | |--leaf "28" | | | `--leaf "44" | | `--[dendrogram w/ 2 branches and 13 members at h = 25.7] | | |--[dendrogram w/ 2 branches and 7 members at h = 18.6] | | | |--[dendrogram w/ 2 branches and 2 members at h = 12.8] | | | | |--leaf "32" | | | | `--leaf "38" | | | `--[dendrogram w/ 2 branches and 5 members at h = 16.4] | | | |--[dendrogram w/ 2 branches and 3 members at h = 8.43] | | | | |--leaf "49" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 4.56] | | | | |--leaf "29" | | | | `--leaf "40" | | | `--[dendrogram w/ 2 branches and 2 members at h = 11.2] | | | |--leaf "16" | | | `--leaf "23" | | `--[dendrogram w/ 2 branches and 6 members at h = 19.5] | | |--[dendrogram w/ 2 branches and 2 members at h = 12.7] | | | |--leaf "10" | | | `--leaf "22" | | `--[dendrogram w/ 2 branches and 4 members at h = 16.9] | | |--leaf "3" | | `--[dendrogram w/ 2 branches and 3 members at h = 9.63] | | |--leaf "21" | | `--[dendrogram w/ 2 branches and 2 members at h = 6] | | |--leaf "9" | | `--leaf "15" | `--[dendrogram w/ 2 branches and 10 members at h = 27.8] | |--[dendrogram w/ 2 branches and 2 members at h = 6.83] | | |--leaf "50" | | `--leaf "61" | `--[dendrogram w/ 2 branches and 8 members at h = 21.1] | |--[dendrogram w/ 2 branches and 4 members at h = 17.4] | | |--leaf "6" | | `--[dendrogram w/ 2 branches and 3 members at h = 10.6] | | |--leaf "39" | | `--[dendrogram w/ 2 branches and 2 members at h = 6.76] | | |--leaf "41" | | `--leaf "56" | `--[dendrogram w/ 2 branches and 4 members at h = 19.0] | |--leaf "52" | `--[dendrogram w/ 2 branches and 3 members at h = 10.5] | |--leaf "30" | `--[dendrogram w/ 2 branches and 2 members at h = 4.06] | |--leaf "45" | `--leaf "46" `--[dendrogram w/ 2 branches and 18 members at h = 49.5] |--[dendrogram w/ 2 branches and 2 members at h = 29.2] | |--leaf "43" | `--leaf "55" `--[dendrogram w/ 2 branches and 16 members at h = 46.1] |--[dendrogram w/ 2 branches and 3 members at h = 20] | |--leaf "19" | `--[dendrogram w/ 2 branches and 2 members at h = 18.2] | |--leaf "7" | `--leaf "31" `--[dendrogram w/ 2 branches and 13 members at h = 22.1] |--[dendrogram w/ 2 branches and 5 members at h = 14.8] | |--leaf "4" | `--[dendrogram w/ 2 branches and 4 members at h = 11.5] | |--[dendrogram w/ 2 branches and 2 members at h = 2.65] | | |--leaf "11" | | `--leaf "17" | `--[dendrogram w/ 2 branches and 2 members at h = 3.76] | |--leaf "5" | `--leaf "20" `--[dendrogram w/ 2 branches and 8 members at h = 17.4] |--[dendrogram w/ 2 branches and 3 members at h = 11.4] | |--leaf "1" | `--[dendrogram w/ 2 branches and 2 members at h = 7.61] | |--leaf "8" | `--leaf "14" `--[dendrogram w/ 2 branches and 5 members at h = 15.5] |--leaf "2" `--[dendrogram w/ 2 branches and 4 members at h = 13.5] |--leaf "25" `--[dendrogram w/ 2 branches and 3 members at h = 10.8] |--leaf "37" `--[dendrogram w/ 2 branches and 2 members at h = 5.03] |--leaf "13" `--leaf "26" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1lwku1226336189.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/27drv1226336189.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) + } --[dendrogram w/ 2 branches and 10 members at h = 202] |--leaf 10 `--[dendrogram w/ 2 branches and 9 members at h = 84] |--[dendrogram w/ 2 branches and 4 members at h = 42] | |--[dendrogram w/ 2 branches and 2 members at h = 31.7] | | |--leaf 5 | | `--leaf 6 | `--[dendrogram w/ 2 branches and 2 members at h = 36] | |--leaf 7 | `--leaf 9 `--[dendrogram w/ 2 branches and 5 members at h = 57.3] |--[dendrogram w/ 2 branches and 2 members at h = 33.8] | |--leaf 2 | `--leaf 3 `--[dendrogram w/ 2 branches and 3 members at h = 46.3] |--leaf 8 `--[dendrogram w/ 2 branches and 2 members at h = 43.7] |--leaf 1 `--leaf 4 > > #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/3wilg1226336189.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/4fghn1226336190.tab") + } > > system("convert tmp/1lwku1226336189.ps tmp/1lwku1226336189.png") > system("convert tmp/27drv1226336189.ps tmp/27drv1226336189.png") > > > proc.time() user system elapsed 0.968 0.319 1.097