[adegenet-commits] r842 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 4 21:23:42 CET 2011


Author: jombart
Date: 2011-03-04 21:23:41 +0100 (Fri, 04 Mar 2011)
New Revision: 842

Modified:
   pkg/R/find.clust.R
Log:
minor change - switching computer


Modified: pkg/R/find.clust.R
===================================================================
--- pkg/R/find.clust.R	2011-03-04 15:09:36 UTC (rev 841)
+++ pkg/R/find.clust.R	2011-03-04 20:23:41 UTC (rev 842)
@@ -8,7 +8,7 @@
 ######################
 find.clusters.data.frame <- function(x, clust=NULL, n.pca=NULL, n.clust=NULL, stat=c("BIC", "AIC", "WSS"), choose.n.clust=TRUE,
                                      criterion=c("diffNgroup", "min","goesup", "smoothNgoesup", "goodfit"),
-                                     max.n.clust=round(nrow(x)/10), n.iter=1e5, n.start=10, center=TRUE, scale=TRUE, ...){
+                                     max.n.clust=round(nrow(x)/10), n.iter=1e5, n.start=10, center=TRUE, scale=TRUE, ..., dudi=NULL){
 
     ## CHECKS ##
     if(!require(ade4, quiet=TRUE)) stop("ade4 library is required.")
@@ -40,7 +40,12 @@
     ## PERFORM PCA ##
     maxRank <- min(dim(x))
 
-    pcaX <- dudi.pca(x, center = center, scale = scale, scannf = FALSE, nf=maxRank)
+    if(is.null(dudi)){
+        pcaX <- dudi.pca(x, center = center, scale = scale, scannf = FALSE, nf=maxRank)
+    } else {
+        if(!inherits(dudi,"dudi")) stop("dudi provided but is not a dudi object")
+        pcaX <- dudi
+    }
 
     ## select the number of retained PC for PCA
     if(is.null(n.pca)){



More information about the adegenet-commits mailing list