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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 9 14:08:16 CET 2013


Author: jarioksa
Date: 2013-01-09 14:08:16 +0100 (Wed, 09 Jan 2013)
New Revision: 2355

Modified:
   pkg/vegan/R/stressplot.R
Log:
stressplot.default works only with isoMDS results and says it loud

Modified: pkg/vegan/R/stressplot.R
===================================================================
--- pkg/vegan/R/stressplot.R	2013-01-09 12:47:41 UTC (rev 2354)
+++ pkg/vegan/R/stressplot.R	2013-01-09 13:08:16 UTC (rev 2355)
@@ -70,10 +70,17 @@
 `stressplot.default` <-
     function(object, dis, pch, p.col = "blue", l.col = "red", lwd = 2, ...)
 {
+    ## the default function only works with metaMDS or MASS::isoMDS results
+    if (!(inherits(object, "metaMDS") ||
+        all(c("points", "stress") %in% names(object))))
+        stop("can be used only with objects that are compatible with MASS::isoMDS results")
     require(MASS) || stop("Needs MASS package")
     if (missing(dis))
-        dis <- metaMDSredist(object)
-    if (attr(dis, "Size") != nrow(object$points))
+        if (inherits(object, "metaMDS"))
+            dis <- metaMDSredist(object)
+        else
+            stop("needs dissimilarities 'dis'")
+     if (attr(dis, "Size") != nrow(object$points))
         stop("Dimensions do not match in ordination and dissimilarities")
     shep <- Shepard(dis, object$points)
     stress <- sum((shep$y - shep$yf)^2)/sum(shep$y^2)



More information about the Vegan-commits mailing list