[Vegan-commits] r1971 - in pkg/permute: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Oct 31 17:21:05 CET 2011
Author: gsimpson
Date: 2011-10-31 17:21:04 +0100 (Mon, 31 Oct 2011)
New Revision: 1971
Modified:
pkg/permute/R/shuffle-utils.R
pkg/permute/inst/ChangeLog
Log:
shuffleStrata assumed samples were in contiguous blocks
Modified: pkg/permute/R/shuffle-utils.R
===================================================================
--- pkg/permute/R/shuffle-utils.R 2011-10-31 16:20:20 UTC (rev 1970)
+++ pkg/permute/R/shuffle-utils.R 2011-10-31 16:21:04 UTC (rev 1971)
@@ -2,27 +2,27 @@
`shuffleStrata` <- function(strata, type, mirror = FALSE, start = NULL,
flip = NULL, nrow, ncol, start.row = NULL,
start.col = NULL) {
- lev <- length(levels(strata))
+ lev <- length(LEVS <- levels(strata))
ngr <- length(strata) / lev
- sp <- split(seq(along = strata), strata)
- if(type == "free") {
- unname(do.call(c, sp[shuffleFree(lev, lev)]))
- } else if(type == "series") {
- unname(do.call(c,
- sp[shuffleSeries(seq_len(lev),
- mirror = mirror,
- start = start,
- flip = flip)]))
- } else if(type == "grid") {
- unname(do.call(c,
- sp[shuffleGrid(nrow = nrow, ncol = ncol,
- mirror = mirror,
- start.row = start.row,
- start.col = start.col,
- flip = flip)]))
+ SEQ <- seq_len(lev)
+ sp <- split(out <- seq_along(strata), strata)
+ perm <- if(type == "free") {
+ shuffleFree(lev, lev)
+ } else if (type == "series") {
+ shuffleSeries(SEQ, mirror = mirror, start = start,
+ flip = flip)
+ } else if (type == "grid") {
+ shuffleGrid(nrow = nrow, ncol = ncol, mirror = mirror,
+ start.row = start.row, start.col = start.col,
+ flip = flip)
} else {
stop("Invalid permutation type.")
}
+ for(i in SEQ) {
+ want <- which(strata == LEVS[i])
+ out[want] <- sp[[perm[i]]]
+ }
+ out
}
`shuffleGrid` <- function(nrow, ncol, mirror = FALSE, start.row = NULL,
Modified: pkg/permute/inst/ChangeLog
===================================================================
--- pkg/permute/inst/ChangeLog 2011-10-31 16:20:20 UTC (rev 1970)
+++ pkg/permute/inst/ChangeLog 2011-10-31 16:21:04 UTC (rev 1971)
@@ -15,6 +15,9 @@
* shuffleGrid: was doing random flipping of permutations even
if `mirror = FALSE` for the `constant = TRUE` case.
+ * shuffleStrata: assumed that the samples were in contiguous
+ blocks. Reporter by Cajo ter Braak
+
Version 0.6-1 (released to CRAN on September 7, 2011)
* NAMESPACE: export(permuplot)
More information about the Vegan-commits
mailing list