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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jul 26 16:57:42 CEST 2009


Author: jarioksa
Date: 2009-07-26 16:57:40 +0200 (Sun, 26 Jul 2009)
New Revision: 905

Modified:
   pkg/vegan/R/metaMDS.R
   pkg/vegan/inst/ChangeLog
Log:
metaMDS accepts now user supplied dissimilarities

Modified: pkg/vegan/R/metaMDS.R
===================================================================
--- pkg/vegan/R/metaMDS.R	2009-07-22 20:57:32 UTC (rev 904)
+++ pkg/vegan/R/metaMDS.R	2009-07-26 14:57:40 UTC (rev 905)
@@ -4,11 +4,22 @@
               plot = FALSE, previous.best, old.wa = FALSE, ...) 
 {
     commname <- deparse(substitute(comm))
-    if (inherits(comm, "dist"))
-        stop("metaMDS does not accept dist objects, but needs original data frame")
-    dis <- metaMDSdist(comm, distance = distance, autotransform = autotransform, 
-                       noshare = noshare, trace = trace, commname = commname, 
-                       ...)
+    if (inherits(comm, "dist")) {
+        dis <- comm
+        if (is.null(attr(dis, "method")))
+            attr(dis, "method") <- "user supplied"
+        wascores <- FALSE
+    } else if (length(dim(comm) == 2) && ncol(comm) == nrow(comm) &&
+                all(comm == t(comm))) {
+        dis <- as.dist(m)
+        attr(dis, "method") <- "user supplied"
+        wascores <- FALSE
+    } else {
+        dis <- metaMDSdist(comm, distance = distance,
+                           autotransform = autotransform, 
+                           noshare = noshare, trace = trace,
+                           commname = commname, ...)
+    }
     if (missing(previous.best)) 
         previous.best <- NULL
     out <- metaMDSiter(dis, k = k, trymax = trymax, trace = trace, 
@@ -27,6 +38,8 @@
     out$points <- points
     out$species <- wa
     out$call <- match.call()
+    if (is.null(out$data))
+        out$data <- commname
     class(out) <- "metaMDS"
     out
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-07-22 20:57:32 UTC (rev 904)
+++ pkg/vegan/inst/ChangeLog	2009-07-26 14:57:40 UTC (rev 905)
@@ -4,6 +4,11 @@
 
 Version 1.16-22 (opened July 15, 2009)
 
+	* metaMDS: accepts now user supplied dissimilarities either as a
+	"dist" structure or as symmetric square matrix (on Susan Letcher's
+	wish). As a side effect, dissimilarity matrices are now correctly
+	detected and will not be wrongly treated as raw data.
+
 	* summary.cca: fix in 1.16-20 failed if all variables were
 	continuous and there were no centroids of factor levels.
 	



More information about the Vegan-commits mailing list