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(10263,5953,2935,3018,3346,1622,1724,964,461,503,10310,5973,2945,3028,3358,1628,1730,979,469,510,10355,5995,2957,3038,3369,1634,1735,992,477,515,10396,6016,2967,3049,3380,1640,1740,1000,480,520,10446,6043,2980,3063,3396,1648,1748,1007,484,523,10511,6078,2997,3081,3414,1657,1757,1019,490,529,10585,6117,3017,3100,3436,1668,1768,1031,497,534,10667,6162,3040,3122,3456,1678,1778,1049,506,543),dim=c(10,8),dimnames=list(c('Totaal','VGtotaal','VGmannen','VGvrouwen','WGtotaal','WGmannen','WGvrouwen','Btotaal','Bmannen','Bvrouwen'),1:8)) > y <- array(NA,dim=c(10,8),dimnames=list(c('Totaal','VGtotaal','VGmannen','VGvrouwen','WGtotaal','WGmannen','WGvrouwen','Btotaal','Bmannen','Bvrouwen'),1:8)) > 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' > 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 8 members at h = 743] |--[dendrogram w/ 2 branches and 4 members at h = 167] | |--[dendrogram w/ 2 branches and 2 members at h = 51.2] | | |--leaf "3" | | `--leaf "4" | `--[dendrogram w/ 2 branches and 2 members at h = 58] | |--leaf "1" | `--leaf "2" `--[dendrogram w/ 2 branches and 4 members at h = 280] |--[dendrogram w/ 2 branches and 2 members at h = 82.2] | |--leaf "5" | `--leaf "6" `--[dendrogram w/ 2 branches and 2 members at h = 104] |--leaf "7" `--leaf "8" > mysub <- paste('Method: ',par1) > postscript(file="/var/www/html/rcomp/tmp/118991226421447.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/2pnb21226421447.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/3znun1226421447.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/4pzkf1226421447.tab") + } > > system("convert tmp/118991226421447.ps tmp/118991226421447.png") > system("convert tmp/2pnb21226421447.ps tmp/2pnb21226421447.png") convert: unable to open image `tmp/2pnb21226421447.ps': No such file or directory. convert: missing an image filename `tmp/2pnb21226421447.png'. > > > proc.time() user system elapsed 0.633 0.190 1.160