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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 18 14:35:35 CEST 2010


Author: jarioksa
Date: 2010-10-18 14:35:34 +0200 (Mon, 18 Oct 2010)
New Revision: 1337

Modified:
   pkg/vegan/R/isomap.R
Log:
isomap more robust against vagaries of cmdscale

Modified: pkg/vegan/R/isomap.R
===================================================================
--- pkg/vegan/R/isomap.R	2010-10-18 08:54:50 UTC (rev 1336)
+++ pkg/vegan/R/isomap.R	2010-10-18 12:35:34 UTC (rev 1337)
@@ -4,12 +4,11 @@
     dist <- isomapdist(dist, ...)
     out <- cmdscale(dist, k=ndim, eig=TRUE)
     ## some versions of cmdscale may return NaN points corresponding
-    ## to negative eigenvalues
-    if (any(out$eig < 0)) {
-        out$eig <- out$eig[out$eig > 0]
-        out$points <- out$points[, seq_along(out$eig), drop = FALSE]
+    ## to negative eigenvalues.
+    if ((naxes <- sum(out$eig > 0)) < ndim) {
+        out$points <- out$points[, seq(naxes), drop = FALSE]
         warning(gettextf("isomap returns only %d axes with positive eigenvalues",
-                         length(out$eig)))
+                         naxes))
     }
     npoints <- nrow(out$points)
     net <- matrix(FALSE, nrow=npoints, ncol=npoints)



More information about the Vegan-commits mailing list