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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 9 22:05:10 CET 2012


Author: gsimpson
Date: 2012-02-09 22:05:09 +0100 (Thu, 09 Feb 2012)
New Revision: 2080

Modified:
   pkg/vegan/R/betadisper.R
Log:
droplevels should be applied to  so we don't work with empty groups

Modified: pkg/vegan/R/betadisper.R
===================================================================
--- pkg/vegan/R/betadisper.R	2012-02-09 21:03:03 UTC (rev 2079)
+++ pkg/vegan/R/betadisper.R	2012-02-09 21:05:09 UTC (rev 2080)
@@ -28,8 +28,11 @@
         type <- "median"
     type <- match.arg(type)
     ## checks for groups - need to be a factor for later
-    if(!is.factor(group))
+    if(!is.factor(group)) {
         group <- as.factor(group)
+    } else { ## if already a factor, drop empty levels
+        group <- droplevels(group)
+    }
     n <- attr(d, "Size")
     x <- matrix(0, ncol = n, nrow = n)
     x[row(x) > col(x)] <- d^2



More information about the Vegan-commits mailing list