R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-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(112,118,132,129,121,135,148,148,136,119,104,118,115,126,141,135,125,149,170,170,158,133,114,140,145,150,178,163,172,178,199,199,184,162,146,166,171,180,193,181,183,218,230,242,209,191,172,194,196,196),dim=c(1,50),dimnames=list(c('pallavi'),1:50)) > y <- array(NA,dim=c(1,50),dimnames=list(c('pallavi'),1:50)) > 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 = 'ALL' > par1 = 'complete' > ylab = 'height' > xlab = 'cases' > main = 'Dendrogram' > par4 <- 'TRUE' > par3 <- 'FALSE' > par2 <- 'ALL' > par1 <- 'complete' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa, P., (2012), Hierarchical Clustering (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_hierarchicalclustering.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > 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 50 members at h = 138] |--[dendrogram w/ 2 branches and 24 members at h = 46] | |--[dendrogram w/ 2 branches and 14 members at h = 21] | | |--[dendrogram w/ 2 branches and 6 members at h = 5] | | | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | | | |--leaf "25" | | | | `--leaf "35" | | | `--[dendrogram w/ 2 branches and 4 members at h = 2] | | | |--leaf "26" | | | `--[dendrogram w/ 2 branches and 3 members at h = 1] | | | |--leaf "18" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "7" | | | `--leaf "8" | | `--[dendrogram w/ 2 branches and 8 members at h = 12] | | |--[dendrogram w/ 2 branches and 3 members at h = 4] | | | |--leaf "4" | | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "3" | | | `--leaf "22" | | `--[dendrogram w/ 2 branches and 5 members at h = 6] | | |--[dendrogram w/ 2 branches and 3 members at h = 1] | | | |--leaf "9" | | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "6" | | | `--leaf "16" | | `--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "15" | | `--leaf "24" | `--[dendrogram w/ 2 branches and 10 members at h = 22] | |--[dendrogram w/ 2 branches and 6 members at h = 8] | | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | | |--leaf "14" | | | `--leaf "17" | | `--[dendrogram w/ 2 branches and 4 members at h = 3] | | |--leaf "5" | | `--[dendrogram w/ 2 branches and 3 members at h = 1] | | |--leaf "10" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "2" | | `--leaf "12" | `--[dendrogram w/ 2 branches and 4 members at h = 11] | |--leaf "11" | `--[dendrogram w/ 2 branches and 3 members at h = 3] | |--leaf "1" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "13" | `--leaf "23" `--[dendrogram w/ 2 branches and 26 members at h = 84] |--[dendrogram w/ 2 branches and 4 members at h = 33] | |--[dendrogram w/ 2 branches and 2 members at h = 9] | | |--leaf "42" | | `--leaf "45" | `--[dendrogram w/ 2 branches and 2 members at h = 12] | |--leaf "43" | `--leaf "44" `--[dendrogram w/ 2 branches and 22 members at h = 41] |--[dendrogram w/ 2 branches and 9 members at h = 14] | |--[dendrogram w/ 2 branches and 5 members at h = 2] | | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | | |--leaf "29" | | | `--leaf "47" | | `--[dendrogram w/ 2 branches and 3 members at h = 1] | | |--leaf "37" | | `--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "19" | | `--leaf "20" | `--[dendrogram w/ 2 branches and 4 members at h = 8] | |--leaf "21" | `--[dendrogram w/ 2 branches and 3 members at h = 4] | |--leaf "36" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "28" | `--leaf "34" `--[dendrogram w/ 2 branches and 13 members at h = 21] |--[dendrogram w/ 2 branches and 6 members at h = 6] | |--[dendrogram w/ 2 branches and 2 members at h = 1] | | |--leaf "33" | | `--leaf "41" | `--[dendrogram w/ 2 branches and 4 members at h = 3] | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "27" | | `--leaf "30" | `--[dendrogram w/ 2 branches and 2 members at h = 1] | |--leaf "38" | `--leaf "40" `--[dendrogram w/ 2 branches and 7 members at h = 8] |--[dendrogram w/ 2 branches and 4 members at h = 3] | |--[dendrogram w/ 2 branches and 2 members at h = 0] | | |--leaf "31" | | `--leaf "32" | `--[dendrogram w/ 2 branches and 2 members at h = 0] | |--leaf "49" | `--leaf "50" `--[dendrogram w/ 2 branches and 3 members at h = 3] |--leaf "46" `--[dendrogram w/ 2 branches and 2 members at h = 1] |--leaf "39" `--leaf "48" > mysub <- paste('Method: ',par1) > postscript(file="/var/fisher/rcomp/tmp/14n351379322794.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/fisher/rcomp/tmp/21oug1379322794.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/3qqty1379322794.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/fisher/rcomp/tmp/4rdr61379322794.tab") + } > > try(system("convert tmp/14n351379322794.ps tmp/14n351379322794.png",intern=TRUE)) character(0) > try(system("convert tmp/21oug1379322794.ps tmp/21oug1379322794.png",intern=TRUE)) convert: unable to open image `tmp/21oug1379322794.ps': @ error/blob.c/OpenBlob/2587. convert: missing an image filename `tmp/21oug1379322794.png' @ error/convert.c/ConvertImageCommand/3011. character(0) attr(,"status") [1] 1 Warning message: running command 'convert tmp/21oug1379322794.ps tmp/21oug1379322794.png' had status 1 > > > proc.time() user system elapsed 0.951 0.245 1.173