I am using some functions from package clusterSim to evaluate the best clusters layout. Here is the features vector I am using to cluater 12 signals:
> alpha.vec [1] 0.8540039 0.8558350 0.8006592 0.8066406 0.8322754 0.8991699 0.8212891 [8] 0.8815918 0.9050293 0.9174194 0.8613281 0.8425293 In the following I pasted an excerpt of my program: #################################################################### library(clusterSim) setwd("C:/Documents and Settings/Monville/SpAn-Tests/Signals-Classification-Dir/Classification-by-Signal-Dir") ## LOAD DONOHO ALPHA FILE features.tab <- read.table("Signals-Alpha-and-Zero-Moments.txt",header=T) ## EXTRACT SIGNALS ID insig <- features.tab[,"SignalID"] ## GENERATE DISTANCE MATRIX LABELS rwn <- NULL for(i in 1:length(insig)) { rwn <- c(rwn,as.character(insig[i])) } ## EXTRACT FEATURES VECTOR alpha.vec <- features.tab[,"Signal_Donoho_Alpha"] ## CALCULATE DISTANCE MATRIX - EUCLIDEAN DISTANCE ## ATTACH SIGNAL LABELS dist.mat <- dist(as.matrix(alpha.vec),method = "euclidean") yy <- as.matrix(dist.mat) rownames(yy) <- rwn nc.min <- 2 #MINIMUM CLUSTERS NUM. nc.max <- length(alpha.vec) -1 #MAXIMUM CLUSTERS NUM. ## --------------------------------- PAM - INDEX.G1 ------------------------------------------ res <- array(0,c(nc.max - nc.min +1,2)) res[,1] <- nc.min:nc.max clusters <- NULL for (nc in nc.min:nc.max) { cl <- pam(dist.mat,nc,diss=TRUE) res[nc-nc.min+1,2] <- G1 <- index.G1(as.matrix(alpha.vec),cl$cluster,d=dist.mat,centrotypes="medoids") clusters <- rbind(clusters, cl$cluster) } ############################################################################### I get the following error whenever I use index.G1: > nc <- 2 > cl <- pam(dist.mat,nc,diss=TRUE) > cl Medoids: ID [1,] 5 5 [2,] 9 9 Clustering vector: [1] 1 1 1 1 1 2 1 2 2 2 1 1 Objective function: build swap 0.01873272 0.01620992 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" > ndex.G1(as.matrix(alpha.vec),cl$cluster,d=dist.mat,centrotypes="medoids") Error: could not find function "ndex.G1" > index.G1(as.matrix(alpha.vec),cl$cluster,d=dist.mat,centrotypes="medoids") Error in centers[i, ] <- .medoid(x[cl == i, ], d[cl == i, cl == i]) : number of items to replace is not a multiple of replacement length Please, notice that the same code work if I call index.G2, index.G3, index.S Whay it doesn't work with index.G1 ? Thank you very much. Maura tutti i telefonini TIM! [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.