[Vegan-commits] r2980 - in pkg/vegan: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 26 10:14:59 CET 2015


Author: jarioksa
Date: 2015-11-26 10:14:58 +0100 (Thu, 26 Nov 2015)
New Revision: 2980

Modified:
   pkg/vegan/DESCRIPTION
   pkg/vegan/R/anosim.R
   pkg/vegan/R/bioenv.default.R
   pkg/vegan/R/gdispweight.R
   pkg/vegan/R/mrpp.R
   pkg/vegan/R/rarefy.R
Log:
Squashed commit of the following:

commit 43e0233943ef8c6f56b6f1a716beb13a3b32ecfc
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date:   Wed Nov 25 13:14:35 2015 +0200

    rarefy gave false warnings if data was a vector or dropped to vector

    also improved ordering of tests for warnings and errors

    (cherry picked from commit 223ec5fbfa800318428f689d2be7da89ef5d4316)

commit b73869871ed2ec227527c528e127ea5b42a4018d
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date:   Wed Nov 25 12:11:30 2015 +0200

    community data cannot be a matrix, but it must be a data.frame

    (cherry picked from commit cd45945e36c2d5c6273b05910e95211e0a88f1d9)

commit 42738f74db28ffccd6000253ec10f490233bc779
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date:   Thu Nov 19 19:54:39 2015 +0200

    cleaner test for symmetric matrices that also works for data frames

    (cherry picked from commit c10762873165c108e9591b1f0e38fbd5af13a87c)

commit c35d409d072f04dfd201f4cebaa0f83fc3c16f80
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date:   Thu Nov 19 19:35:37 2015 +0200

    cleaner test for distances in symmetric matrices or data frames

    earlier failed with data.frames

    (cherry picked from commit dc815de504391a344264320cecfff0dfd6cabb84)

commit 4f5e2bb57baf3638cd7e9ce49199cc08898740a2
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date:   Thu Nov 19 19:29:55 2015 +0200

    clean and correct test for distances in symmetric matrices

    as.dist() was not done after successful test for symmetric
    matrices and analysis failed later when it assumed data are
    no dist objects.

    (cherry picked from commit 96bb628b9833980d4d1b7bbb8ea33c6870c43283)

commit 670c79d5fe9f5101be4ec0b73fee2a4856e54d12
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date:   Thu Nov 26 10:58:41 2015 +0200

    vegan 2.3-2 was released: update version

    version 2.3-3 may never be released, but head on towards 2.4-0.
    However, changes must go to a new number just in case.

Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION	2015-11-19 08:27:00 UTC (rev 2979)
+++ pkg/vegan/DESCRIPTION	2015-11-26 09:14:58 UTC (rev 2980)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 2.3-2
-Date: 2015-11-19
+Version: 2.3-3
+Date: 2015-11-26
 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, 
    Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, 
    M. Henry H. Stevens, Helene Wagner  

Modified: pkg/vegan/R/anosim.R
===================================================================
--- pkg/vegan/R/anosim.R	2015-11-19 08:27:00 UTC (rev 2979)
+++ pkg/vegan/R/anosim.R	2015-11-26 09:14:58 UTC (rev 2980)
@@ -5,12 +5,13 @@
     EPS <- sqrt(.Machine$double.eps)
     if (inherits(dat, "dist")) 
         x <- dat
-    else if (is.matrix(dat) && nrow(dat) == ncol(dat) && all(dat[lower.tri(dat)] == 
-        t(dat)[lower.tri(dat)])) {
-        x <- dat
+    else if ((is.matrix(dat) || is.data.frame(dat)) &&
+             isSymmetric(unname(as.matrix(dat)))) {
+        x <- as.dist(dat)
         attr(x, "method") <- "user supplied square matrix"
     }
-    else x <- vegdist(dat, method = distance)
+    else
+        x <- vegdist(dat, method = distance)
     if (any(x < -sqrt(.Machine$double.eps)))
         warning("some dissimilarities are negative -- is this intentional?")
     sol <- c(call = match.call())

Modified: pkg/vegan/R/bioenv.default.R
===================================================================
--- pkg/vegan/R/bioenv.default.R	2015-11-19 08:27:00 UTC (rev 2979)
+++ pkg/vegan/R/bioenv.default.R	2015-11-26 09:14:58 UTC (rev 2980)
@@ -70,8 +70,8 @@
         index <- attr(comdis, "method")
         if (is.null(index))
             index <- "unspecified"
-    } else if (is.matrix(comm) && nrow(comm) == ncol(comm) &&
-             isTRUE(all.equal(comm, t(comm)))) {
+    } else if ((is.matrix(comm) || is.data.frame(comm)) &&
+               isSymmetric(unname(as.matrix(comm)))) {
         comdis <- as.dist(comm)
         index <- "supplied square matrix"
     } else {

Modified: pkg/vegan/R/gdispweight.R
===================================================================
--- pkg/vegan/R/gdispweight.R	2015-11-19 08:27:00 UTC (rev 2979)
+++ pkg/vegan/R/gdispweight.R	2015-11-26 09:14:58 UTC (rev 2980)
@@ -26,6 +26,7 @@
     family <- quasipoisson()
     V <- family$variance
     ## fit models to all species separately and extract results
+    comm <- as.data.frame(comm)
     mods <- lapply(comm, function(y) glm.fit(x, y, family = family))
     y <- sapply(mods, '[[', "y")
     mu <- sapply(mods, fitted)

Modified: pkg/vegan/R/mrpp.R
===================================================================
--- pkg/vegan/R/mrpp.R	2015-11-19 08:27:00 UTC (rev 2979)
+++ pkg/vegan/R/mrpp.R	2015-11-26 09:14:58 UTC (rev 2980)
@@ -14,8 +14,8 @@
     }
     if (inherits(dat, "dist")) 
         dmat <- dat
-    else if (is.matrix(dat) && nrow(dat) == ncol(dat) && all(dat[lower.tri(dat)] == 
-        t(dat)[lower.tri(dat)])) {
+    else if ((is.matrix(dat) || is.data.frame(dat)) &&
+               isSymmetric(unname(as.matrix(dat)))) {
         dmat <- dat
         attr(dmat, "method") <- "user supplied square matrix"
     }

Modified: pkg/vegan/R/rarefy.R
===================================================================
--- pkg/vegan/R/rarefy.R	2015-11-19 08:27:00 UTC (rev 2979)
+++ pkg/vegan/R/rarefy.R	2015-11-26 09:14:58 UTC (rev 2980)
@@ -2,22 +2,23 @@
     function (x, sample, se = FALSE, MARGIN = 1) 
 {
     x <- as.matrix(x)
-    minsample <- min(apply(x, MARGIN, sum))
-    if (any(sample > minsample))
-        warning(
-            gettextf("Requested 'sample' was larger than smallest site maximum (%d)",
-                     minsample))
     ## as.matrix changes an n-vector to a n x 1 matrix
     if (ncol(x) == 1 && MARGIN == 1)
         x <- t(x)
     if (!identical(all.equal(x, round(x)), TRUE))
         stop("function accepts only integers (counts)")
+    minsample <- min(apply(x, MARGIN, sum))
     if (missing(sample)) {
-        sample <- min(apply(x, MARGIN, sum))
-        info <- paste("The size of 'sample' must be given --\nHint: Smallest site maximum", 
-                      sample)
-        stop(info)
+        stop(
+            gettextf(
+                "The size of 'sample' must be given --\nHint: Smallest site maximum %d",
+                minsample))
     }
+    if (any(sample > minsample))
+        warning(
+            gettextf(
+                "Requested 'sample' was larger than smallest site maximum (%d)",
+                minsample))
     rarefun <- function(x, sample) {
         x <- x[x > 0]
         J <- sum(x)



More information about the Vegan-commits mailing list