R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(99.2,96.7,101.0,99.0,98.1,100.1,100.0,100.0,100.0,111.6,104.9,90.6,122.2,104.9,86.5,117.6,109.5,89.7,121.1,110.8,90.6,136.0,112.3,82.8,154.2,109.3,70.1,153.6,105.3,65.4,158.5,101.7,61.3,140.6,95.4,62.5,136.2,96.4,63.6,168.0,97.6,52.6,154.3,102.4,59.7,149.0,101.6,59.5,165.5,103.8,61.3),dim=c(3,17),dimnames=list(c('Cons','Inc','Price'),1:17)) > y <- array(NA,dim=c(3,17),dimnames=list(c('Cons','Inc','Price'),1:17)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par7 = '0' > par6 = '0.5' > par5 = '0.5' > par4 = '0.5' > par3 = '1' > par2 = 'ward' > par1 = 'euclidean' > 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), Agglomerative Nesting (v1.0.1) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_agglomerativehierarchicalclustering.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.numeric(par3) > par4 <- as.numeric(par4) > par5 <- as.numeric(par5) > par6 <- as.numeric(par6) > par7 <- as.numeric(par7) > library(cluster) > if (par2 == 'flexible') + { + if (par3 == 1) pm <- c(par4) + if (par3 == 3) pm <- c(par4,par5,par6) + if (par3 == 4) pm <- c(par4,par5,par6,par7) + ag <- agnes(t(y),metric=par1,method=par2,par.method=pm) + } else { + ag <- agnes(t(y),metric=par1,method=par2) + } > mysub <- paste('Method: ',par2) > summary(ag) Object of class `agnes' from call: agnes(x = t(y), metric = par1, method = par2) Agglomerative coefficient: 0.9520017 Order of objects: [1] 1 2 3 4 5 6 7 8 9 10 11 15 16 14 17 12 13 Merge: [,1] [,2] [1,] -1 -2 [2,] 1 -3 [3,] -6 -7 [4,] -11 -15 [5,] -12 -13 [6,] -9 -10 [7,] -5 3 [8,] 4 -16 [9,] -14 -17 [10,] -4 7 [11,] 6 8 [12,] 11 9 [13,] 10 -8 [14,] 12 5 [15,] 2 13 [16,] 15 14 Height: [1] 1.676305 3.239856 53.158333 11.665190 8.083522 3.840573 [7] 24.826397 147.331077 6.200806 14.422321 4.548626 8.638094 [13] 24.782540 10.971782 36.259867 4.644351 136 dissimilarities, summarized : Min. 1st Qu. Median Mean 3rd Qu. Max. 1.6763 16.8490 32.2880 35.6410 52.2600 84.1240 Metric : euclidean Number of objects : 17 Available components: [1] "order" "height" "ac" "merge" "diss" "call" [7] "method" "order.lab" "data" > postscript(file="/var/www/html/rcomp/tmp/122fl1195140381.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(ag,which.plots=2,main=main,sub=mysub,xlab=xlab,ylab=ylab) > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/281pa1195140381.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(ag,which.plots=1,main='Banner',sub=mysub,xlab=ylab,ylab=xlab) > dev.off() null device 1 > load(file='/var/www/html/rcomp/createtable') > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Agglomerative Nesting (Hierarchical Clustering)',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Agglomerative Coefficient',header=TRUE) > a<-table.element(a,ag$ac) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/3a6ra1195140381.tab") > > system("convert tmp/122fl1195140381.ps tmp/122fl1195140381.png") > system("convert tmp/281pa1195140381.ps tmp/281pa1195140381.png") > > > proc.time() user system elapsed 0.826 0.315 2.851