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(604.4 + ,882.5 + ,1.1663 + ,883.9 + ,789.6 + ,1.1372 + ,527.9 + ,773.3 + ,1.1139 + ,756.2 + ,804.3 + ,1.1222 + ,812.9 + ,817.8 + ,1.1692 + ,655.6 + ,836.7 + ,1.1702 + ,707.6 + ,721.8 + ,1.2286 + ,612.6 + ,760.8 + ,1.2613 + ,659.2 + ,841.4 + ,1.2646 + ,833.4 + ,1045.6 + ,1.2262 + ,727.8 + ,949.2 + ,1.1985 + ,797.2 + ,850.1 + ,1.2007 + ,753 + ,957.4 + ,1.2138 + ,762 + ,851.8 + ,1.2266 + ,613.7 + ,913.9 + ,1.2176 + ,759.2 + ,888 + ,1.2218 + ,816.4 + ,973.8 + ,1.249 + ,736.8 + ,927.6 + ,1.2991 + ,680.1 + ,833 + ,1.3408 + ,736.5 + ,879.5 + ,1.3119 + ,637.2 + ,797.3 + ,1.3014 + ,801.9 + ,834.5 + ,1.3201 + ,772.3 + ,735.1 + ,1.2938 + ,897.3 + ,835 + ,1.2694 + ,792.1 + ,892.8 + ,1.2165 + ,826.8 + ,697.2 + ,1.2037 + ,666.8 + ,821.1 + ,1.2292 + ,906.6 + ,732.7 + ,1.2256 + ,871.4 + ,797.6 + ,1.2015 + ,891 + ,866.3 + ,1.1786 + ,739.2 + ,826.3 + ,1.1856 + ,833.6 + ,778.6 + ,1.2103 + ,715.6 + ,779.2 + ,1.1938 + ,871.6 + ,951 + ,1.202 + ,751.6 + ,692.3 + ,1.2271 + ,1005.5 + ,841.4 + ,1.277 + ,681.2 + ,857.3 + ,1.265 + ,837.3 + ,760.7 + ,1.2684 + ,674.7 + ,841.2 + ,1.2811 + ,806.3 + ,810.3 + ,1.2727 + ,860.2 + ,1007.4 + ,1.2611 + ,689.8 + ,931.3 + ,1.2881 + ,691.6 + ,931.2 + ,1.3213 + ,682.6 + ,855.8 + ,1.2999 + ,800.1 + ,858.4 + ,1.3074 + ,1023.7 + ,925.9 + ,1.3242 + ,733.5 + ,930.7 + ,1.3516 + ,875.3 + ,1037.6 + ,1.3511 + ,770.2 + ,979.2 + ,1.3419 + ,1005.7 + ,942.6 + ,1.3716 + ,982.3 + ,843.9 + ,1.3622 + ,742.9 + ,854.3 + ,1.3896 + ,974.2 + ,1029.8 + ,1.4227 + ,822.3 + ,944 + ,1.4684 + ,773.2 + ,856.4 + ,1.457 + ,750.9 + ,1059.4 + ,1.4718 + ,708 + ,959.3 + ,1.4748 + ,690 + ,941.5 + ,1.5527 + ,652.8 + ,1026.4 + ,1.575 + ,620.7 + ,921.3 + ,1.5557 + ,461.9 + ,968 + ,1.5553) + ,dim=c(3 + ,61) + ,dimnames=list(c('UitvoerVS' + ,'InvoerBE' + ,'EURUSD') + ,1:61)) > y <- array(NA,dim=c(3,61),dimnames=list(c('UitvoerVS','InvoerBE','EURUSD'),1:61)) > 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 = '20' > par1 = 'median' > 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 61 members at h = 348] |--[dendrogram w/ 2 branches and 5 members at h = 119] | |--leaf "53" | `--[dendrogram w/ 2 branches and 4 members at h = 83.3] | |--[dendrogram w/ 2 branches and 2 members at h = 23.3] | | |--leaf "36" | | `--leaf "51" | `--[dendrogram w/ 2 branches and 2 members at h = 24.6] | |--leaf "46" | `--leaf "50" `--[dendrogram w/ 2 branches and 56 members at h = 164] |--leaf "61" `--[dendrogram w/ 2 branches and 55 members at h = 149] |--leaf "3" `--[dendrogram w/ 2 branches and 54 members at h = 118] |--[dendrogram w/ 2 branches and 34 members at h = 93.2] | |--[dendrogram w/ 2 branches and 13 members at h = 62.7] | | |--[dendrogram w/ 2 branches and 4 members at h = 52.6] | | | |--leaf "33" | | | `--[dendrogram w/ 2 branches and 3 members at h = 47.6] | | | |--leaf "7" | | | `--[dendrogram w/ 2 branches and 2 members at h = 47.5] | | | |--leaf "23" | | | `--leaf "35" | | `--[dendrogram w/ 2 branches and 9 members at h = 60.6] | | |--[dendrogram w/ 2 branches and 7 members at h = 24.8] | | | |--[dendrogram w/ 2 branches and 2 members at h = 2.05] | | | | |--leaf "37" | | | | `--leaf "44" | | | `--[dendrogram w/ 2 branches and 5 members at h = 13.9] | | | |--leaf "27" | | | `--[dendrogram w/ 2 branches and 4 members at h = 16.7] | | | |--[dendrogram w/ 2 branches and 2 members at h = 5.92] | | | | |--leaf "6" | | | | `--leaf "9" | | | `--[dendrogram w/ 2 branches and 2 members at h = 9.82] | | | |--leaf "19" | | | `--leaf "39" | | `--[dendrogram w/ 2 branches and 2 members at h = 44] | | |--leaf "8" | | `--leaf "21" | `--[dendrogram w/ 2 branches and 21 members at h = 82.4] | |--[dendrogram w/ 2 branches and 19 members at h = 67.6] | | |--[dendrogram w/ 2 branches and 13 members at h = 43.8] | | | |--leaf "25" | | | `--[dendrogram w/ 2 branches and 12 members at h = 37] | | | |--[dendrogram w/ 2 branches and 5 members at h = 24.0] | | | | |--[dendrogram w/ 2 branches and 2 members at h = 10] | | | | | |--leaf "5" | | | | | `--leaf "40" | | | | `--[dendrogram w/ 2 branches and 3 members at h = 17.9] | | | | |--leaf "22" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 8.8] | | | | |--leaf "12" | | | | `--leaf "45" | | | `--[dendrogram w/ 2 branches and 7 members at h = 37.4] | | | |--[dendrogram w/ 2 branches and 5 members at h = 21.8] | | | | |--[dendrogram w/ 2 branches and 3 members at h = 21.8] | | | | | |--leaf "52" | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 12.1] | | | | | |--leaf "14" | | | | | `--leaf "55" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 24.2] | | | | |--leaf "16" | | | | `--leaf "20" | | | `--[dendrogram w/ 2 branches and 2 members at h = 27.8] | | | |--leaf "4" | | | `--leaf "31" | | `--[dendrogram w/ 2 branches and 6 members at h = 58.2] | | |--[dendrogram w/ 2 branches and 2 members at h = 31.9] | | | |--leaf "24" | | | `--leaf "30" | | `--[dendrogram w/ 2 branches and 4 members at h = 41.4] | | |--[dendrogram w/ 2 branches and 2 members at h = 14.8] | | | |--leaf "2" | | | `--leaf "29" | | `--[dendrogram w/ 2 branches and 2 members at h = 18.3] | | |--leaf "32" | | `--leaf "38" | `--[dendrogram w/ 2 branches and 2 members at h = 87.3] | |--leaf "26" | `--leaf "28" `--[dendrogram w/ 2 branches and 20 members at h = 118] |--[dendrogram w/ 2 branches and 3 members at h = 34.9] | |--leaf "1" | `--[dendrogram w/ 2 branches and 2 members at h = 10.2] | |--leaf "15" | `--leaf "60" `--[dendrogram w/ 2 branches and 17 members at h = 93.3] |--leaf "59" `--[dendrogram w/ 2 branches and 16 members at h = 70.5] |--leaf "56" `--[dendrogram w/ 2 branches and 15 members at h = 68.2] |--[dendrogram w/ 2 branches and 9 members at h = 44.3] | |--leaf "49" | `--[dendrogram w/ 2 branches and 8 members at h = 29.5] | |--[dendrogram w/ 2 branches and 4 members at h = 24.4] | | |--leaf "13" | | `--[dendrogram w/ 2 branches and 3 members at h = 20.2] | | |--leaf "11" | | `--[dendrogram w/ 2 branches and 2 members at h = 4.53] | | |--leaf "18" | | `--leaf "47" | `--[dendrogram w/ 2 branches and 4 members at h = 26.4] | |--leaf "57" | `--[dendrogram w/ 2 branches and 3 members at h = 9.86] | |--leaf "58" | `--[dendrogram w/ 2 branches and 2 members at h = 1.80] | |--leaf "42" | `--leaf "43" `--[dendrogram w/ 2 branches and 6 members at h = 56.9] |--[dendrogram w/ 2 branches and 3 members at h = 36.2] | |--leaf "10" | `--[dendrogram w/ 2 branches and 2 members at h = 33.8] | |--leaf "41" | `--leaf "48" `--[dendrogram w/ 2 branches and 3 members at h = 47.2] |--leaf "34" `--[dendrogram w/ 2 branches and 2 members at h = 30.4] |--leaf "17" `--leaf "54" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/freestat/rcomp/tmp/1cgu31226407213.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/25l301226407213.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 20 members at h = 297] |--[dendrogram w/ 2 branches and 12 members at h = 137] | |--leaf 17 | `--[dendrogram w/ 2 branches and 11 members at h = 114] | |--[dendrogram w/ 2 branches and 2 members at h = 94] | | |--leaf 15 | | `--leaf 16 | `--[dendrogram w/ 2 branches and 9 members at h = 94.1] | |--leaf 11 | `--[dendrogram w/ 2 branches and 8 members at h = 99] | |--[dendrogram w/ 2 branches and 3 members at h = 71] | | |--leaf 12 | | `--[dendrogram w/ 2 branches and 2 members at h = 70] | | |--leaf 2 | | `--leaf 13 | `--[dendrogram w/ 2 branches and 5 members at h = 87.1] | |--leaf 4 | `--[dendrogram w/ 2 branches and 4 members at h = 74.7] | |--[dendrogram w/ 2 branches and 2 members at h = 68.9] | | |--leaf 6 | | `--leaf 14 | `--[dendrogram w/ 2 branches and 2 members at h = 77.4] | |--leaf 5 | `--leaf 7 `--[dendrogram w/ 2 branches and 8 members at h = 153] |--leaf 3 `--[dendrogram w/ 2 branches and 7 members at h = 159] |--leaf 20 `--[dendrogram w/ 2 branches and 6 members at h = 107] |--leaf 1 `--[dendrogram w/ 2 branches and 5 members at h = 88.7] |--leaf 19 `--[dendrogram w/ 2 branches and 4 members at h = 92] |--leaf 9 `--[dendrogram w/ 2 branches and 3 members at h = 103] |--leaf 18 `--[dendrogram w/ 2 branches and 2 members at h = 76.5] |--leaf 8 `--leaf 10 > > #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/3mjj81226407213.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/4mmei1226407213.tab") + } > > system("convert tmp/1cgu31226407213.ps tmp/1cgu31226407213.png") > system("convert tmp/25l301226407213.ps tmp/25l301226407213.png") > > > proc.time() user system elapsed 1.088 0.451 1.216