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(0.9059,109.86,7.4367,0.8883,108.68,7.4452,0.8924,113.38,7.4431,0.8833,117.12,7.4329,0.8700,116.23,7.4299,0.8758,114.75,7.4324,0.8858,115.81,7.4341,0.9170,115.86,7.4356,0.9554,117.80,7.4330,0.9922,117.11,7.4301,0.9778,116.31,7.4270,0.9808,118.38,7.4271,0.9811,121.57,7.4297,1.0014,121.65,7.4280,1.0183,124.20,7.4264),dim=c(3,15),dimnames=list(c('Dollar','Yen','Kroon'),1:15)) > y <- array(NA,dim=c(3,15),dimnames=list(c('Dollar','Yen','Kroon'),1:15)) > 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 = 'ALL' > 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 15 members at h = 25.3] |--[dendrogram w/ 2 branches and 3 members at h = 3.43] | |--leaf "15" | `--[dendrogram w/ 2 branches and 2 members at h = 0.0826] | |--leaf "13" | `--leaf "14" `--[dendrogram w/ 2 branches and 12 members at h = 19.8] |--[dendrogram w/ 2 branches and 2 members at h = 1.18] | |--leaf "1" | `--leaf "2" `--[dendrogram w/ 2 branches and 10 members at h = 6.68] |--[dendrogram w/ 2 branches and 4 members at h = 1.61] | |--[dendrogram w/ 2 branches and 2 members at h = 0.109] | | |--leaf "4" | | `--leaf "10" | `--[dendrogram w/ 2 branches and 2 members at h = 0.581] | |--leaf "9" | `--leaf "12" `--[dendrogram w/ 2 branches and 6 members at h = 4.06] |--[dendrogram w/ 2 branches and 4 members at h = 0.781] | |--[dendrogram w/ 2 branches and 2 members at h = 0.059] | | |--leaf "7" | | `--leaf "8" | `--[dendrogram w/ 2 branches and 2 members at h = 0.134] | |--leaf "5" | `--leaf "11" `--[dendrogram w/ 2 branches and 2 members at h = 1.37] |--leaf "3" `--leaf "6" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/1b8t51226501971.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/2d9r01226501971.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) + } > > #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/3qbvb1226501971.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/4ntrj1226501972.tab") + } > > system("convert tmp/1b8t51226501971.ps tmp/1b8t51226501971.png") > system("convert tmp/2d9r01226501971.ps tmp/2d9r01226501971.png") convert: unable to open image `tmp/2d9r01226501971.ps': No such file or directory. convert: missing an image filename `tmp/2d9r01226501971.png'. > > > proc.time() user system elapsed 0.625 0.184 0.725