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(2293 + ,4348 + ,440427 + ,1.90 + ,2045 + ,3603 + ,386715 + ,1.76 + ,1532 + ,2700 + ,291787 + ,1.76 + ,1333 + ,2640 + ,278253 + ,1.98 + ,1583 + ,2916 + ,300903 + ,1.84 + ,1712 + ,3180 + ,327695 + ,1.86 + ,2641 + ,4151 + ,471590 + ,1.57 + ,2267 + ,4023 + ,442850 + ,1.77 + ,2126 + ,3431 + ,387181 + ,1.61 + ,2231 + ,3874 + ,420099 + ,1.74 + ,1517 + ,2617 + ,289850 + ,1.73 + ,2010 + ,3580 + ,392468 + ,1.78 + ,2628 + ,5267 + ,549174 + ,2.00 + ,2115 + ,3832 + ,415506 + ,1.81 + ,1829 + ,3441 + ,356662 + ,1.88 + ,1636 + ,3228 + ,338612 + ,1.97 + ,1787 + ,3397 + ,359886 + ,1.90 + ,2122 + ,3971 + ,410547 + ,1.87 + ,2620 + ,4625 + ,495272 + ,1.77 + ,2555 + ,4486 + ,474588 + ,1.76 + ,2337 + ,4131 + ,442893 + ,1.77 + ,2524 + ,4686 + ,477793 + ,1.86 + ,1801 + ,3174 + ,336263 + ,1.76 + ,2417 + ,4282 + ,449838 + ,1.77 + ,2389 + ,4209 + ,451406 + ,1.76 + ,2266 + ,4158 + ,439690 + ,1.83 + ,2135 + ,3936 + ,401513 + ,1.84 + ,1755 + ,3149 + ,326472 + ,1.79 + ,1907 + ,3623 + ,369464 + ,1.90 + ,2178 + ,4230 + ,429525 + ,1.94 + ,2345 + ,4443 + ,464658 + ,1.89 + ,2674 + ,4810 + ,510691 + ,1.80 + ,2765 + ,4853 + ,513151 + ,1.76 + ,2786 + ,5050 + ,538609 + ,1.81 + ,2004 + ,3553 + ,398949 + ,1.77 + ,2589 + ,4674 + ,511635 + ,1.81 + ,2739 + ,5412 + ,554318 + ,1.98 + ,2700 + ,5131 + ,515879 + ,1.90 + ,2459 + ,4856 + ,488122 + ,1.97 + ,1965 + ,3980 + ,401716 + ,2.03 + ,2152 + ,4431 + ,453358 + ,2.06 + ,2379 + ,4606 + ,464884 + ,1.94 + ,2930 + ,5352 + ,571868 + ,1.83 + ,2691 + ,4640 + ,497485 + ,1.72 + ,2852 + ,5170 + ,538214 + ,1.81 + ,2752 + ,4824 + ,502396 + ,1.75 + ,1787 + ,3280 + ,349385 + ,1.84 + ,2580 + ,4706 + ,502427 + ,1.82 + ,2604 + ,4909 + ,514106 + ,1.89 + ,2532 + ,5092 + ,527537 + ,2.01 + ,2265 + ,4911 + ,495918 + ,2.17 + ,1745 + ,3824 + ,376847 + ,2.19 + ,1914 + ,4214 + ,420552 + ,2.20 + ,2148 + ,4449 + ,442679 + ,2.07 + ,2466 + ,4486 + ,478422 + ,1.82 + ,2498 + ,4777 + ,483796 + ,1.91 + ,2512 + ,5132 + ,529032 + ,2.04 + ,2458 + ,4522 + ,482991 + ,1.84 + ,1825 + ,3295 + ,354287 + ,1.81 + ,2267 + ,4281 + ,459146 + ,1.89 + ,2364 + ,4590 + ,473744 + ,1.94 + ,2328 + ,4623 + ,478642 + ,1.99 + ,2034 + ,4075 + ,426208 + ,2.00 + ,1587 + ,3398 + ,348908 + ,2.14 + ,1633 + ,3029 + ,321310 + ,1.85) + ,dim=c(4 + ,65) + ,dimnames=list(c('Cons' + ,'Inc' + ,'Price' + ,'Pric') + ,1:65)) > y <- array(NA,dim=c(4,65),dimnames=list(c('Cons','Inc','Price','Pric'),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 = 'TRUE' > par3 = 'FALSE' > par2 = '20' > par1 = 'single' > 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 = 20407] |--[dendrogram w/ 2 branches and 4 members at h = 11598] | |--leaf "4" | `--[dendrogram w/ 2 branches and 3 members at h = 9119] | |--leaf "5" | `--[dendrogram w/ 2 branches and 2 members at h = 1939] | |--leaf "3" | `--leaf "11" `--[dendrogram w/ 2 branches and 61 members at h = 17551] |--leaf "43" `--[dendrogram w/ 2 branches and 60 members at h = 11659] |--[dendrogram w/ 2 branches and 54 members at h = 10298] | |--[dendrogram w/ 2 branches and 5 members at h = 8568] | | |--[dendrogram w/ 2 branches and 2 members at h = 2355] | | | |--leaf "16" | | | `--leaf "23" | | `--[dendrogram w/ 2 branches and 3 members at h = 5165] | | |--leaf "65" | | `--[dendrogram w/ 2 branches and 2 members at h = 1224] | | |--leaf "6" | | `--leaf "28" | `--[dendrogram w/ 2 branches and 49 members at h = 10166] | |--[dendrogram w/ 2 branches and 30 members at h = 8265] | | |--[dendrogram w/ 2 branches and 5 members at h = 1789] | | | |--leaf "38" | | | `--[dendrogram w/ 2 branches and 4 members at h = 1537] | | | |--[dendrogram w/ 2 branches and 2 members at h = 958] | | | | |--leaf "32" | | | | `--leaf "36" | | | `--[dendrogram w/ 2 branches and 2 members at h = 970] | | | |--leaf "33" | | | `--leaf "49" | | `--[dendrogram w/ 2 branches and 25 members at h = 7156] | | |--[dendrogram w/ 2 branches and 5 members at h = 4915] | | | |--[dendrogram w/ 2 branches and 2 members at h = 211] | | | | |--leaf "46" | | | | `--leaf "48" | | | `--[dendrogram w/ 2 branches and 3 members at h = 1646] | | | |--leaf "44" | | | `--[dendrogram w/ 2 branches and 2 members at h = 791] | | | |--leaf "19" | | | `--leaf "51" | | `--[dendrogram w/ 2 branches and 20 members at h = 6947] | | |--[dendrogram w/ 2 branches and 5 members at h = 2259] | | | |--[dendrogram w/ 2 branches and 3 members at h = 427] | | | | |--leaf "54" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 136] | | | | |--leaf "8" | | | | `--leaf "21" | | | `--[dendrogram w/ 2 branches and 2 members at h = 762] | | | |--leaf "1" | | | `--leaf "26" | | `--[dendrogram w/ 2 branches and 15 members at h = 6727] | | |--[dendrogram w/ 2 branches and 9 members at h = 4352] | | | |--[dendrogram w/ 2 branches and 6 members at h = 3211] | | | | |--[dendrogram w/ 2 branches and 3 members at h = 663] | | | | | |--leaf "22" | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 294] | | | | | |--leaf "55" | | | | | `--leaf "62" | | | | `--[dendrogram w/ 2 branches and 3 members at h = 2216] | | | | |--leaf "7" | | | | `--[dendrogram w/ 2 branches and 2 members at h = 872] | | | | |--leaf "20" | | | | `--leaf "61" | | | `--[dendrogram w/ 2 branches and 3 members at h = 4327] | | | |--leaf "39" | | | `--[dendrogram w/ 2 branches and 2 members at h = 845] | | | |--leaf "56" | | | `--leaf "58" | | `--[dendrogram w/ 2 branches and 6 members at h = 5791] | | |--[dendrogram w/ 2 branches and 3 members at h = 1979] | | | |--leaf "41" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1570] | | | |--leaf "24" | | | `--leaf "25" | | `--[dendrogram w/ 2 branches and 3 members at h = 5515] | | |--leaf "60" | | `--[dendrogram w/ 2 branches and 2 members at h = 281] | | |--leaf "31" | | `--leaf "42" | `--[dendrogram w/ 2 branches and 19 members at h = 9875] | |--[dendrogram w/ 2 branches and 12 members at h = 8832] | | |--[dendrogram w/ 2 branches and 6 members at h = 5659] | | | |--[dendrogram w/ 2 branches and 2 members at h = 3324] | | | | |--leaf "30" | | | | `--leaf "63" | | | `--[dendrogram w/ 2 branches and 4 members at h = 4961] | | | |--leaf "18" | | | `--[dendrogram w/ 2 branches and 3 members at h = 4595] | | | |--leaf "14" | | | `--[dendrogram w/ 2 branches and 2 members at h = 649] | | | |--leaf "10" | | | `--leaf "53" | | `--[dendrogram w/ 2 branches and 6 members at h = 6481] | | |--[dendrogram w/ 2 branches and 3 members at h = 2596] | | | |--leaf "35" | | | `--[dendrogram w/ 2 branches and 2 members at h = 268] | | | |--leaf "27" | | | `--leaf "40" | | `--[dendrogram w/ 2 branches and 3 members at h = 5290] | | |--leaf "12" | | `--[dendrogram w/ 2 branches and 2 members at h = 503] | | |--leaf "2" | | `--leaf "9" | `--[dendrogram w/ 2 branches and 7 members at h = 9581] | |--[dendrogram w/ 2 branches and 5 members at h = 4902] | | |--[dendrogram w/ 2 branches and 2 members at h = 531] | | | |--leaf "47" | | | `--leaf "64" | | `--[dendrogram w/ 2 branches and 3 members at h = 3225] | | |--leaf "17" | | `--[dendrogram w/ 2 branches and 2 members at h = 2379] | | |--leaf "15" | | `--leaf "59" | `--[dendrogram w/ 2 branches and 2 members at h = 7388] | |--leaf "29" | `--leaf "52" `--[dendrogram w/ 2 branches and 6 members at h = 10568] |--[dendrogram w/ 2 branches and 2 members at h = 5147] | |--leaf "13" | `--leaf "37" `--[dendrogram w/ 2 branches and 4 members at h = 9188] |--[dendrogram w/ 2 branches and 2 members at h = 418] | |--leaf "34" | `--leaf "45" `--[dendrogram w/ 2 branches and 2 members at h = 1496] |--leaf "50" `--leaf "57" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1wfyv1226266215.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/2iaxb1226266215.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 = 24257] |--[dendrogram w/ 2 branches and 3 members at h = 12567] | |--leaf 4 | `--[dendrogram w/ 2 branches and 2 members at h = 10088] | |--leaf 3 | `--leaf 5 `--[dendrogram w/ 2 branches and 17 members at h = 21641] |--[dendrogram w/ 2 branches and 7 members at h = 20124] | |--leaf 18 | `--[dendrogram w/ 2 branches and 6 members at h = 19846] | |--leaf 7 | `--[dendrogram w/ 2 branches and 5 members at h = 15195] | |--[dendrogram w/ 2 branches and 3 members at h = 13337] | | |--leaf 9 | | `--[dendrogram w/ 2 branches and 2 members at h = 10131] | | |--leaf 17 | | `--leaf 19 | `--[dendrogram w/ 2 branches and 2 members at h = 14394] | |--leaf 12 | `--leaf 16 `--[dendrogram w/ 2 branches and 10 members at h = 21303] |--[dendrogram w/ 2 branches and 2 members at h = 15508] | |--leaf 1 | `--leaf 13 `--[dendrogram w/ 2 branches and 8 members at h = 19681] |--leaf 8 `--[dendrogram w/ 2 branches and 7 members at h = 16389] |--[dendrogram w/ 2 branches and 2 members at h = 12279] | |--leaf 6 | `--leaf 11 `--[dendrogram w/ 2 branches and 5 members at h = 15641] |--leaf 10 `--[dendrogram w/ 2 branches and 4 members at h = 11949] |--[dendrogram w/ 2 branches and 2 members at h = 7388] | |--leaf 15 | `--leaf 20 `--[dendrogram w/ 2 branches and 2 members at h = 11941] |--leaf 2 `--leaf 14 > > #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/3jfx51226266215.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/4hihu1226266215.tab") + } > > system("convert tmp/1wfyv1226266215.ps tmp/1wfyv1226266215.png") > system("convert tmp/2iaxb1226266215.ps tmp/2iaxb1226266215.png") > > > proc.time() user system elapsed 1.056 0.347 3.940