R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(4930.63,6284.63,13339.63,8935.63,-419.37,1220.63,-5094.37,-5561.37,-2732.37,-316.37,-3929.37,-9291.37,6644.63,2492.63,5997.63,3383.63,-693.37,3945.63,-5128.37,-4368.37,-3414.37,-3313.37,-4619.37,-12400.37,8857.63,6407.63,11407.63,4066.63,3637.63,592.63,-4941.37,-5770.37,-4893.37,-2103.37,-5716.37,-13731.37,8025.63,3452.63,7552.63,2760.63,2001.63,2679.63,-2680.37,-4410.37,-2674.37,1677.63,-3284.37,-10360.37,8467.63,7012.63,6920.63,8835.63,2727.63,3736.63,-2893.37,-5309.37,-2578.37,-580.37,-7526.37,-11589.37,2348.63,991.63,4687.63,3096.63,-2582.37,-339.37,-4070.37,-6127.37,-3062.37,-613.37),dim=c(1,70),dimnames=list(c('voertuigen'),1:70)) > y <- array(NA,dim=c(1,70),dimnames=list(c('voertuigen'),1:70)) > 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 = '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 70 members at h = 217605] |--[dendrogram w/ 2 branches and 37 members at h = 53248] | |--[dendrogram w/ 2 branches and 6 members at h = 7226] | | |--[dendrogram w/ 2 branches and 3 members at h = 2045] | | | |--leaf "36" | | | `--[dendrogram w/ 2 branches and 2 members at h = 811] | | | |--leaf "24" | | | `--leaf "60" | | `--[dendrogram w/ 2 branches and 3 members at h = 2710] | | |--leaf "59" | | `--[dendrogram w/ 2 branches and 2 members at h = 1069] | | |--leaf "12" | | `--leaf "48" | `--[dendrogram w/ 2 branches and 31 members at h = 30379] | |--[dendrogram w/ 2 branches and 14 members at h = 4833] | | |--[dendrogram w/ 2 branches and 5 members at h = 900] | | | |--[dendrogram w/ 2 branches and 2 members at h = 141] | | | | |--leaf "11" | | | | `--leaf "67" | | | `--[dendrogram w/ 2 branches and 3 members at h = 293] | | | |--leaf "23" | | | `--[dendrogram w/ 2 branches and 2 members at h = 42] | | | |--leaf "20" | | | `--leaf "44" | | `--[dendrogram w/ 2 branches and 9 members at h = 2353] | | |--[dendrogram w/ 2 branches and 5 members at h = 481] | | | |--[dendrogram w/ 2 branches and 2 members at h = 48] | | | | |--leaf "31" | | | | `--leaf "33" | | | `--[dendrogram w/ 2 branches and 3 members at h = 253] | | | |--leaf "56" | | | `--[dendrogram w/ 2 branches and 2 members at h = 34] | | | |--leaf "7" | | | `--leaf "19" | | `--[dendrogram w/ 2 branches and 4 members at h = 597] | | |--leaf "68" | | `--[dendrogram w/ 2 branches and 3 members at h = 225] | | |--leaf "8" | | `--[dendrogram w/ 2 branches and 2 members at h = 54] | | |--leaf "32" | | `--leaf "35" | `--[dendrogram w/ 2 branches and 17 members at h = 16040] | |--[dendrogram w/ 2 branches and 6 members at h = 668] | | |--[dendrogram w/ 2 branches and 3 members at h = 114] | | | |--leaf "5" | | | `--[dendrogram w/ 2 branches and 2 members at h = 23] | | | |--leaf "10" | | | `--leaf "66" | | `--[dendrogram w/ 2 branches and 3 members at h = 118] | | |--leaf "17" | | `--[dendrogram w/ 2 branches and 2 members at h = 33] | | |--leaf "58" | | `--leaf "70" | `--[dendrogram w/ 2 branches and 11 members at h = 2363] | |--[dendrogram w/ 2 branches and 5 members at h = 692] | | |--[dendrogram w/ 2 branches and 3 members at h = 144] | | | |--leaf "21" | | | `--[dendrogram w/ 2 branches and 2 members at h = 29] | | | |--leaf "22" | | | `--leaf "47" | | `--[dendrogram w/ 2 branches and 2 members at h = 169] | | |--leaf "55" | | `--leaf "69" | `--[dendrogram w/ 2 branches and 6 members at h = 856] | |--leaf "34" | `--[dendrogram w/ 2 branches and 5 members at h = 243] | |--[dendrogram w/ 2 branches and 2 members at h = 4] | | |--leaf "57" | | `--leaf "65" | `--[dendrogram w/ 2 branches and 3 members at h = 71.3] | |--leaf "9" | `--[dendrogram w/ 2 branches and 2 members at h = 6] | |--leaf "43" | `--leaf "45" `--[dendrogram w/ 2 branches and 33 members at h = 58293] |--[dendrogram w/ 2 branches and 19 members at h = 11363] | |--[dendrogram w/ 2 branches and 9 members at h = 2971] | | |--[dendrogram w/ 2 branches and 2 members at h = 243] | | | |--leaf "1" | | | `--leaf "63" | | `--[dendrogram w/ 2 branches and 7 members at h = 1245] | | |--[dendrogram w/ 2 branches and 3 members at h = 406] | | | |--leaf "64" | | | `--[dendrogram w/ 2 branches and 2 members at h = 69] | | | |--leaf "16" | | | `--leaf "38" | | `--[dendrogram w/ 2 branches and 4 members at h = 528] | | |--[dendrogram w/ 2 branches and 2 members at h = 99] | | | |--leaf "29" | | | `--leaf "54" | | `--[dendrogram w/ 2 branches and 2 members at h = 121] | | |--leaf "18" | | `--leaf "28" | `--[dendrogram w/ 2 branches and 10 members at h = 4700] | |--[dendrogram w/ 2 branches and 5 members at h = 595] | | |--[dendrogram w/ 2 branches and 3 members at h = 75] | | | |--leaf "42" | | | `--[dendrogram w/ 2 branches and 2 members at h = 33] | | | |--leaf "40" | | | `--leaf "53" | | `--[dendrogram w/ 2 branches and 2 members at h = 144] | | |--leaf "14" | | `--leaf "61" | `--[dendrogram w/ 2 branches and 5 members at h = 1642] | |--[dendrogram w/ 2 branches and 2 members at h = 324] | | |--leaf "41" | | `--leaf "46" | `--[dendrogram w/ 2 branches and 3 members at h = 608] | |--leaf "30" | `--[dendrogram w/ 2 branches and 2 members at h = 229] | |--leaf "6" | `--leaf "62" `--[dendrogram w/ 2 branches and 14 members at h = 13036] |--[dendrogram w/ 2 branches and 2 members at h = 1932] | |--leaf "3" | `--leaf "27" `--[dendrogram w/ 2 branches and 12 members at h = 8681] |--[dendrogram w/ 2 branches and 5 members at h = 1193] | |--[dendrogram w/ 2 branches and 3 members at h = 111] | | |--leaf "4" | | `--[dendrogram w/ 2 branches and 2 members at h = 22] | | |--leaf "25" | | `--leaf "52" | `--[dendrogram w/ 2 branches and 2 members at h = 442] | |--leaf "37" | `--leaf "49" `--[dendrogram w/ 2 branches and 7 members at h = 1916] |--[dendrogram w/ 2 branches and 4 members at h = 552] | |--leaf "15" | `--[dendrogram w/ 2 branches and 3 members at h = 357] | |--leaf "13" | `--[dendrogram w/ 2 branches and 2 members at h = 123] | |--leaf "2" | `--leaf "26" `--[dendrogram w/ 2 branches and 3 members at h = 751] |--leaf "39" `--[dendrogram w/ 2 branches and 2 members at h = 92] |--leaf "50" `--leaf "51" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1s4f61262179069.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/2t1px1262179069.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 = 68462] |--[dendrogram w/ 2 branches and 9 members at h = 18966] | |--[dendrogram w/ 2 branches and 5 members at h = 4043] | | |--[dendrogram w/ 2 branches and 2 members at h = 635] | | | |--leaf 9 | | | `--leaf 14 | | `--[dendrogram w/ 2 branches and 3 members at h = 1283] | | |--leaf 10 | | `--[dendrogram w/ 2 branches and 2 members at h = 720] | | |--leaf 7 | | `--leaf 8 | `--[dendrogram w/ 2 branches and 4 members at h = 5683] | |--[dendrogram w/ 2 branches and 2 members at h = 1736] | | |--leaf 15 | | `--leaf 17 | `--[dendrogram w/ 2 branches and 2 members at h = 2300] | |--leaf 11 | `--leaf 20 `--[dendrogram w/ 2 branches and 11 members at h = 23389] |--[dendrogram w/ 2 branches and 6 members at h = 5980] | |--[dendrogram w/ 2 branches and 2 members at h = 1429] | | |--leaf 5 | | `--leaf 6 | `--[dendrogram w/ 2 branches and 4 members at h = 2519] | |--[dendrogram w/ 2 branches and 2 members at h = 762] | | |--leaf 12 | | `--leaf 19 | `--[dendrogram w/ 2 branches and 2 members at h = 1192] | |--leaf 1 | `--leaf 13 `--[dendrogram w/ 2 branches and 5 members at h = 8396] |--[dendrogram w/ 2 branches and 2 members at h = 1932] | |--leaf 3 | `--leaf 16 `--[dendrogram w/ 2 branches and 3 members at h = 2348] |--leaf 4 `--[dendrogram w/ 2 branches and 2 members at h = 828] |--leaf 2 `--leaf 18 > > #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/3ip9i1262179069.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/4mm9p1262179069.tab") + } > > try(system("convert tmp/1s4f61262179069.ps tmp/1s4f61262179069.png",intern=TRUE)) character(0) > try(system("convert tmp/2t1px1262179069.ps tmp/2t1px1262179069.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.765 0.330 0.903