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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 4 12:14:30 CET 2015


Author: jarioksa
Date: 2015-03-04 12:14:29 +0100 (Wed, 04 Mar 2015)
New Revision: 2934

Modified:
   pkg/vegan/R/adonis.R
   pkg/vegan/R/anosim.R
   pkg/vegan/R/bioenv.default.R
Log:
Merge branch 'cran-2.2' into r-forge-svn-local

Modified: pkg/vegan/R/adonis.R
===================================================================
--- pkg/vegan/R/adonis.R	2015-02-23 08:41:47 UTC (rev 2933)
+++ pkg/vegan/R/adonis.R	2015-03-04 11:14:29 UTC (rev 2934)
@@ -25,6 +25,8 @@
     grps <- grps[qrhs$pivot][1:qrhs$rank]
     u.grps <- unique(grps)
     nterms <- length(u.grps) - 1
+    if (nterms < 1)
+        stop("right-hand-side of formula has no usable terms")
     H.s <- lapply(2:length(u.grps),
                   function(j) {Xj <- rhs[, grps %in% u.grps[1:j] ]
                                qrX <- qr(Xj, tol=TOL)

Modified: pkg/vegan/R/anosim.R
===================================================================
--- pkg/vegan/R/anosim.R	2015-02-23 08:41:47 UTC (rev 2933)
+++ pkg/vegan/R/anosim.R	2015-03-04 11:14:29 UTC (rev 2934)
@@ -14,6 +14,8 @@
         warning("some dissimilarities are negative -- is this intentional?")
     sol <- c(call = match.call())
     grouping <- as.factor(grouping)
+    if (length(levels(grouping)) < 2)
+        stop("there should be more than one class level")
     matched <- function(irow, icol, grouping) {
         grouping[irow] == grouping[icol]
     }

Modified: pkg/vegan/R/bioenv.default.R
===================================================================
--- pkg/vegan/R/bioenv.default.R	2015-02-23 08:41:47 UTC (rev 2933)
+++ pkg/vegan/R/bioenv.default.R	2015-03-04 11:14:29 UTC (rev 2934)
@@ -29,7 +29,16 @@
         partial <- dist(partial)
     if (!is.null(partial) && !pmatch(method, c("pearson", "spearman"), nomatch=FALSE))
         stop("method ", method, " invalid in partial bioenv")
+    ## remove constant variables
+    constant <- apply(env, 2, function(x) length(unique(x))) <= 1
+    if (any(constant)) {
+        warning("the following variables are constant and were removed: ",
+                paste(colnames(env)[constant], collapse=", "))
+        env <- env[, !constant, drop = FALSE]
+    }
     n <- ncol(env)
+    if (n < 1)
+        stop("no usable variables in 'env'")
     ntake <- 2^n - 1
     ndone <- 0
     upto <- min(upto, n)



More information about the Vegan-commits mailing list