[Vegan-commits] r2843 - in pkg/permute: . R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 26 20:21:11 CET 2014


Author: gsimpson
Date: 2014-01-26 20:21:11 +0100 (Sun, 26 Jan 2014)
New Revision: 2843

Modified:
   pkg/permute/DESCRIPTION
   pkg/permute/R/allPerms.R
   pkg/permute/inst/ChangeLog
Log:
fix bug in plot-level permutations; now uses cbindAllPerms() for consistency. Bump to 0.8-3.

Modified: pkg/permute/DESCRIPTION
===================================================================
--- pkg/permute/DESCRIPTION	2014-01-26 19:20:03 UTC (rev 2842)
+++ pkg/permute/DESCRIPTION	2014-01-26 19:21:11 UTC (rev 2843)
@@ -1,6 +1,6 @@
 Package: permute
 Title: Functions for generating restricted permutations of data
-Version: 0.8-2
+Version: 0.8-3
 Date: $Date$
 Authors at R: c(person(given = "Gavin L.", family = "Simpson",
                     email = "ucfagls at gmail.com",

Modified: pkg/permute/R/allPerms.R
===================================================================
--- pkg/permute/R/allPerms.R	2014-01-26 19:20:03 UTC (rev 2842)
+++ pkg/permute/R/allPerms.R	2014-01-26 19:21:11 UTC (rev 2843)
@@ -157,19 +157,21 @@
                         ord <- switch(typeW,
                                       free = allFree(tab[j]),
                                       series = allSeries(tab[j], np, mirrorW))
-                        permW <- nrow(ord)
-                        if(j == 1) {
-                            a <- 1
-                            b <- nperms / np
-                        } else {
-                            b <- b / np
-                            a <- nperms / (b * np)
-                        }
-                        res[[j]] <- matrix(rep(repMat(ord+add[j], a),
-                                               each = b),
-                                           ncol = tab[j])
+                        res[[j]] <- ord
+                        ## permW <- nrow(ord)
+                        ## if(j == 1) {
+                        ##     a <- 1
+                        ##     b <- nperms / np
+                        ## } else {
+                        ##     b <- b / np
+                        ##     a <- nperms / (b * np)
+                        ## }
+                        ## res[[j]] <- matrix(rep(repMat(ord+add[j], a),
+                        ##                        each = b),
+                        ##                    ncol = tab[j])
                     }
-                    res <- do.call(cbind, res)
+                    ##res <- do.call(cbind, res)
+                    res <- cbindAllPerms(res)
                     sp <- split(obs, strataP)
                     res <- t(apply(res, 1,
                                    function(x, inds, o) {o[inds] <- inds[x]; o},
@@ -184,21 +186,14 @@
                                series = allSeries(pg, np, mirrorW),
                                grid = allGrid(pg, np, dimW[1],
                                dimW[2], mirrorW, constantW))
-                    permW <- nrow(ord)
-                    add <- seq(from = 0, by = pg, length.out = ng)
                     res <- vector(mode = "list", length = ng)
-                    a <- 1
-                    b <- np / permW
+                    ss <- seq(0, to = prod(pg, ng-1), by = pg)
                     for(i in seq_len(ng)) {
-                        res[[i]] <- matrix(rep(repMat(ord+add[i], a),
-                                               each = b),
-                                           ncol = pg)
-                        a <- a*permW
-                        b <- b/permW
+                        res[[i]] <- ord + ss[i]
                     }
-                    res <- do.call(cbind, res)
+                    res <- cbindAllPerms(res)
                     sp <- split(obs, strataP)
-                    res <- t(apply(res, 1,
+                    res2 <- t(apply(res, 1,
                                    function(x, inds, o) {o[inds] <- inds[x]; o},
                                    unlist(sp), obs))
                 }

Modified: pkg/permute/inst/ChangeLog
===================================================================
--- pkg/permute/inst/ChangeLog	2014-01-26 19:20:03 UTC (rev 2842)
+++ pkg/permute/inst/ChangeLog	2014-01-26 19:21:11 UTC (rev 2843)
@@ -2,6 +2,14 @@
 
 permute ChangeLog
 
+Version 0.8-3
+
+	* allPerms: with free permutations *within* plots, `allPerms()`
+	was not returning the indices in the original data but in the
+	permutation indices within plots.
+
+	Reported by: Joris Meys
+
 Version 0.8-2
 
 	* allPerms: with free permutations *within* blocks, `allPerms()`



More information about the Vegan-commits mailing list