[Vegan-commits] r1773 - in pkg/vegan: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 29 19:00:07 CEST 2011


Author: jarioksa
Date: 2011-08-29 19:00:07 +0200 (Mon, 29 Aug 2011)
New Revision: 1773

Modified:
   pkg/vegan/R/monoMDS.R
   pkg/vegan/inst/ChangeLog
Log:
monoMDS checks its input

Modified: pkg/vegan/R/monoMDS.R
===================================================================
--- pkg/vegan/R/monoMDS.R	2011-08-29 14:56:47 UTC (rev 1772)
+++ pkg/vegan/R/monoMDS.R	2011-08-29 17:00:07 UTC (rev 1773)
@@ -1,10 +1,18 @@
-monoMDS <-
+`monoMDS` <-
     function(dist, y, k = 2,
              model = c("global", "local", "linear", "hybrid"),
              threshold = 0.8, maxit = 200, weakties = TRUE, stress = 1,
              scaling = TRUE, pc = TRUE, smin = 0.00001, sfgrmin = 0.00001,
              sratmax=0.99999, ...) 
 {
+    ## Check that 'dist' are distances or a symmetric square matrix
+    if (!(inherits(dist, "dist") || (is.matrix(dist) || is.data.frame(dist))
+          && ncol(dist) == nrow(dist)
+          && isTRUE(all.equal(dist[lower.tri(dist)], t(dist)[lower.tri(dist)]))))
+        stop("'dist' must be a distance object (class \"dist\") or a symmetric square matrix")
+    if (any(dist < -sqrt(.Machine$double.eps)))
+        warning("some dissimilarities are negative -- is this intentional?")
+    ## match.arg
     model <- match.arg(model)
     ## save 'dist' attributes to display in print()
     distmethod <- attr(dist, "method")

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-08-29 14:56:47 UTC (rev 1772)
+++ pkg/vegan/inst/ChangeLog	2011-08-29 17:00:07 UTC (rev 1773)
@@ -5,7 +5,8 @@
 Version 1.92-2 (opened August 28, 2011)
 
 	* monoMDS: saves and displays info on the dissimilarities used,
-	and displays the number of points.
+	and displays the number of points. Checks that input is
+	dissimilarities, and warns on negative ones.
 
 	* MDSrotate: metaMDSrotate() was renamed to MDSrotate(), and
 	metaMDSrotate() was .Deprecated. 



More information about the Vegan-commits mailing list