[adegenet-commits] r530 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 12 13:48:51 CET 2010


Author: jombart
Date: 2010-01-12 13:48:50 +0100 (Tue, 12 Jan 2010)
New Revision: 530

Modified:
   pkg/R/find.clust.R
Log:
reading from console now forces the answer to be an integer


Modified: pkg/R/find.clust.R
===================================================================
--- pkg/R/find.clust.R	2010-01-11 12:14:30 UTC (rev 529)
+++ pkg/R/find.clust.R	2010-01-12 12:48:50 UTC (rev 530)
@@ -46,7 +46,10 @@
         cumVar <- 100 * cumsum(pcaX$eig)/sum(pcaX$eig)
         plot(cumVar, xlab="Number of retained PCs", ylab="Cumulative variance (%)", main="Variance explained by PCA")
         cat("Choose the number PCs to retain (>=1): ")
-        n.pca <- as.integer(readLines(n = 1))
+        n.pca <- NA
+        while(is.na(n.pca)){
+            n.pca <- as.integer(readLines(n = 1))
+        }
     }
 
      ## keep relevant PCs - stored in XU
@@ -103,7 +106,10 @@
             plot(c(1,nbClust), myStat, xlab="Number of clusters", ylab=myLab, main=myTitle, type="b", col="blue")
             abline(h=0, lty=2, col="red")
             cat("Choose the number of clusters (>=2: ")
-            n.clust <- max(1, as.integer(readLines(n = 1)))
+            n.clust <- NA
+            while(is.na(n.clust)){
+                n.clust <- max(1, as.integer(readLines(n = 1)))
+            }
         } else {
             if(criterion=="min") {
                 n.clust <- which.min(myStat)



More information about the adegenet-commits mailing list