R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(30.81,25.68,43.51,40.22,18.60,41.18,36.29,14.44,49.27,38.74,14.71,46.55,27.96,32.38,39.66,39.80,23.64,36.56,40.71,7.46,51.84,41.84,19.04,39.12,34.72,23.47,41.81,35.98,12.12,51.90,47.82,6.45,45.73,44.45,11.20,44.35,49.55,8.29,42.15,36.75,14.08,49.17,49.67,5.55,44.78,38.94,16.51,44.55,41.80,12.04,46.16,33.99,25.23,40.78,50.38,11.75,37.86,27.53,22.82,49.65,36.04,12.06,51.91,41.18,22.03,36.79,39.94,8.21,51.86,40.06,9.45,50.49,41.98,16.49,41.52),dim=c(3,25),dimnames=list(c('Prop2574','NoProp2574','No_PersPr2574'),1:25)) > y <- array(NA,dim=c(3,25),dimnames=list(c('Prop2574','NoProp2574','No_PersPr2574'),1:25)) > 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 25 members at h = 95.9] |--[dendrogram w/ 2 branches and 10 members at h = 40.1] | |--[dendrogram w/ 2 branches and 5 members at h = 11.7] | | |--[dendrogram w/ 2 branches and 2 members at h = 2.13] | | | |--leaf "6" | | | `--leaf "22" | | `--[dendrogram w/ 2 branches and 3 members at h = 3.3] | | |--leaf "25" | | `--[dendrogram w/ 2 branches and 2 members at h = 2.66] | | |--leaf "2" | | `--leaf "8" | `--[dendrogram w/ 2 branches and 5 members at h = 13.3] | |--leaf "20" | `--[dendrogram w/ 2 branches and 4 members at h = 12.7] | |--leaf "5" | `--[dendrogram w/ 2 branches and 3 members at h = 5.29] | |--leaf "1" | `--[dendrogram w/ 2 branches and 2 members at h = 2.17] | |--leaf "9" | `--leaf "18" `--[dendrogram w/ 2 branches and 15 members at h = 50.3] |--[dendrogram w/ 2 branches and 4 members at h = 10.6] | |--leaf "19" | `--[dendrogram w/ 2 branches and 3 members at h = 4.7] | |--leaf "13" | `--[dendrogram w/ 2 branches and 2 members at h = 2.27] | |--leaf "11" | `--leaf "15" `--[dendrogram w/ 2 branches and 11 members at h = 20.8] |--[dendrogram w/ 2 branches and 4 members at h = 9.16] | |--[dendrogram w/ 2 branches and 2 members at h = 2.7] | | |--leaf "4" | | `--leaf "16" | `--[dendrogram w/ 2 branches and 2 members at h = 3.32] | |--leaf "12" | `--leaf "17" `--[dendrogram w/ 2 branches and 7 members at h = 17.1] |--[dendrogram w/ 2 branches and 3 members at h = 2.54] | |--leaf "24" | `--[dendrogram w/ 2 branches and 2 members at h = 1.08] | |--leaf "7" | `--leaf "23" `--[dendrogram w/ 2 branches and 4 members at h = 6.67] |--[dendrogram w/ 2 branches and 2 members at h = 0.0854] | |--leaf "10" | `--leaf "21" `--[dendrogram w/ 2 branches and 2 members at h = 0.593] |--leaf "3" `--leaf "14" > mysub <- paste('Method: ',par1) > postscript(file="/var/wessaorg/rcomp/tmp/18qgi1329489430.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2em881329489430.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/3s44p1329489430.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/wessaorg/rcomp/tmp/4enmt1329489430.tab") + } > > try(system("convert tmp/18qgi1329489430.ps tmp/18qgi1329489430.png",intern=TRUE)) character(0) > try(system("convert tmp/2em881329489430.ps tmp/2em881329489430.png",intern=TRUE)) convert: unable to open image `tmp/2em881329489430.ps': No such file or directory @ blob.c/OpenBlob/2480. convert: missing an image filename `tmp/2em881329489430.png' @ convert.c/ConvertImageCommand/2838. character(0) Warning message: running command 'convert tmp/2em881329489430.ps tmp/2em881329489430.png' had status 1 > > > proc.time() user system elapsed 0.531 0.144 0.735