[Vegan-commits] r1216 - in branches/1.17: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 3 20:27:19 CEST 2010


Author: gsimpson
Date: 2010-06-03 20:27:18 +0200 (Thu, 03 Jun 2010)
New Revision: 1216

Modified:
   branches/1.17/R/betadisper.R
   branches/1.17/inst/ChangeLog
Log:
merge r1214 to the 1.17 branch and document

Modified: branches/1.17/R/betadisper.R
===================================================================
--- branches/1.17/R/betadisper.R	2010-06-03 18:21:08 UTC (rev 1215)
+++ branches/1.17/R/betadisper.R	2010-06-03 18:27:18 UTC (rev 1216)
@@ -1,6 +1,13 @@
 `betadisper` <-
     function(d, group, type = c("median","centroid"))
 {
+    ## inline function for spatial medians
+    spatialMed <- function(vectors, group, pos) {
+        axes <- seq_len(NCOL(vectors))
+        spMedPos <- ordimedian(vectors, group, choices = axes[pos])
+        spMedNeg <- ordimedian(vectors, group, choices = axes[!pos])
+        return(cbind(spMedPos, spMedNeg))
+    }
     ## Tolerance for zero Eigenvalues
     TOL <- 1e-7
     ## uses code from stats:::cmdscale by R Core Development Team
@@ -53,7 +60,7 @@
     centroids <-
         switch(type,
                centroid = apply(vectors, 2, function(x) tapply(x, group, mean)),
-               median = ordimedian(vectors, group, choices = 1:ncol(vectors))
+               median = spatialMed(vectors, group, pos)
                )
     ## for each of the groups, calculate distance to centroid for
     ## observation in the group

Modified: branches/1.17/inst/ChangeLog
===================================================================
--- branches/1.17/inst/ChangeLog	2010-06-03 18:21:08 UTC (rev 1215)
+++ branches/1.17/inst/ChangeLog	2010-06-03 18:27:18 UTC (rev 1216)
@@ -2,6 +2,12 @@
 
 VEGAN RELEASE VERSIONS at http://cran.r-project.org/
 
+Version 1.17-3 (not yet released)
+
+	* betadisper: 'type = "median"', the default, was not computing
+	the spatial median on the real and imaginary axes separately.
+	Reported by Marek Omelka.
+
 Version 1.17-2 (released March 8, 2010)
 
 	* ordistep: merged r1131, 1165 (adds 'anova' item to the result



More information about the Vegan-commits mailing list