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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 22 18:59:07 CET 2013


Author: gsimpson
Date: 2013-11-22 18:59:07 +0100 (Fri, 22 Nov 2013)
New Revision: 2744

Modified:
   pkg/vegan/DESCRIPTION
   pkg/vegan/R/permutest.cca.R
Log:
using update is dangerous in functions; use the new setFoo<- functions instead; this means we now depend on permute 0.7-8 or later

Modified: pkg/vegan/DESCRIPTION
===================================================================
--- pkg/vegan/DESCRIPTION	2013-11-21 20:34:39 UTC (rev 2743)
+++ pkg/vegan/DESCRIPTION	2013-11-22 17:59:07 UTC (rev 2744)
@@ -6,7 +6,7 @@
    Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, 
    M. Henry H. Stevens, Helene Wagner  
 Maintainer: Jari Oksanen <jari.oksanen at oulu.fi>
-Depends: permute (>= 0.7-5), lattice, R (>= 2.14.0)
+Depends: permute (>= 0.7-8), lattice, R (>= 2.14.0)
 Suggests: MASS, mgcv, cluster, parallel, scatterplot3d, rgl, tcltk
 Description: Ordination methods, diversity analysis and other
   functions for community and vegetation ecologists.

Modified: pkg/vegan/R/permutest.cca.R
===================================================================
--- pkg/vegan/R/permutest.cca.R	2013-11-21 20:34:39 UTC (rev 2743)
+++ pkg/vegan/R/permutest.cca.R	2013-11-22 17:59:07 UTC (rev 2744)
@@ -7,7 +7,7 @@
 `permutest.cca` <-
     function (x, permutations = how(nperm=99),
               model = c("reduced", "direct", "full"), first = FALSE,
-              strata = NULL, parallel = getOption("mc.cores") , ...) 
+              strata = NULL, parallel = getOption("mc.cores") , ...)
 {
     ## do something sensible with insensible input (no constraints)
     if (is.null(x$CCA)) {
@@ -53,7 +53,7 @@
                 Q <- qr(XY)
             }
             tmp <- qr.fitted(Q, Y)
-            if (first) 
+            if (first)
                 cca.ev <- La.svd(tmp, nv = 0, nu = 0)$d[1]^2
             else cca.ev <- sum(tmp * tmp)
             if (isPartial || first) {
@@ -74,15 +74,15 @@
         Chi.z <- x$CCA$tot.chi
         names(Chi.z) <- "Model"
         q <- x$CCA$qrank
-    }  
-    ## Set up 
+    }
+    ## Set up
     Chi.xz <- x$CA$tot.chi
     names(Chi.xz) <- "Residual"
     r <- nrow(x$CA$Xbar) - x$CCA$QR$rank - 1
-    if (model == "full") 
+    if (model == "full")
         Chi.tot <- Chi.xz
     else Chi.tot <- Chi.z + Chi.xz
-    if (!isCCA) 
+    if (!isCCA)
         Chi.tot <- Chi.tot * (nrow(x$CCA$Xbar) - 1)
     F.0 <- (Chi.z/q)/(Chi.xz/r)
     Q <- x$CCA$QR
@@ -99,10 +99,10 @@
             Z <- sweep(Z, 1, sqrt(w), "/")
         }
     }
-    if (model == "reduced" || model == "direct") 
+    if (model == "reduced" || model == "direct")
         E <- x$CCA$Xbar
     else E <- x$CA$Xbar
-    if (isPartial && model == "direct") 
+    if (isPartial && model == "direct")
         E <- E + Y.Z
     ## Save dimensions
     N <- nrow(E)
@@ -111,7 +111,7 @@
         if (isPartial)
             Zcol <- ncol(Z)
     }
-    if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) 
+    if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE))
         runif(1)
     seed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE)
     ## permutations is either a single number, a how() structure or a
@@ -123,9 +123,9 @@
     if (!is.null(strata)) {
         if (!inherits(permutations, "how"))
             stop("'strata' can be used only with simple permutation or with 'how()'")
-        if (!is.null(permutations$block))
+        if (!is.null(getBlocks(permutations)))
             stop("'strata' cannot be applied when 'blocks' are defined in 'how()'")
-        permutations <- update(permutations, blocks = strata)
+        setBlocks(permutations) <- strata
     }
     ## now permutations is either a how() structure or a permutation
     ## matrix. Make it to a matrix if it is "how"



More information about the Vegan-commits mailing list