[Vegan-commits] r1433 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 3 21:41:29 CET 2011


Author: jarioksa
Date: 2011-01-03 21:41:28 +0100 (Mon, 03 Jan 2011)
New Revision: 1433

Modified:
   pkg/vegan/R/capscale.R
Log:
cmdscale() vagaries: inaccurate add=T and returning zero eigenvalue

Modified: pkg/vegan/R/capscale.R
===================================================================
--- pkg/vegan/R/capscale.R	2011-01-03 17:54:26 UTC (rev 1432)
+++ pkg/vegan/R/capscale.R	2011-01-03 20:41:28 UTC (rev 1433)
@@ -67,8 +67,12 @@
     ## handle negative eigenvalues and therefore we normally use
     ## wcmdscale. If we have 'add = TRUE' there will be no negative
     ## eigenvalues and this is not a problem.
-    if (add)
+    if (add) {
         X <- cmdscale(X, k = k, eig = TRUE, add = add)
+        ## All eigenvalues *should* be positive, but see that they are
+        X$points <- X$points[, X$eig[-(k+1)] > 0]
+        X$eig <- X$eig[X$eig > 0]
+    }
     else
         X <- wcmdscale(X, eig = TRUE)
     if (is.null(rownames(X$points))) 



More information about the Vegan-commits mailing list