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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 6 18:14:29 CET 2013


Author: gsimpson
Date: 2013-11-06 18:14:29 +0100 (Wed, 06 Nov 2013)
New Revision: 2660

Modified:
   pkg/permute/R/shuffleSet2.R
   pkg/permute/inst/ChangeLog
Log:
fix issue in unsplitting block-level permutations into a single whole set

Modified: pkg/permute/R/shuffleSet2.R
===================================================================
--- pkg/permute/R/shuffleSet2.R	2013-11-06 13:18:19 UTC (rev 2659)
+++ pkg/permute/R/shuffleSet2.R	2013-11-06 17:14:29 UTC (rev 2660)
@@ -8,7 +8,7 @@
         else
             nset <- np
     }
-    
+
     sn <- seq_len(n) ## sequence of samples in order of input
 
     ## need to check number of permutations won't blow up
@@ -21,19 +21,20 @@
         Block <- getStrata(control, which = "blocks")
         if(is.null(Block))
             Block <- factor(rep(1, n))
-        
+
         ## split sn on basis of Block
         spln <- split(sn, Block)
         nb <- length(spln) ## number of blocks
-        
+
         ## result list
         out <- vector(mode = "list", length = nb)
-        
+
         ## loop over spln and shuffle in each split
         for(i in seq_len(nb)) {
             out[[i]] <- doShuffleSet(spln[[i]], nset = nset, control)
         }
-        out <- do.call(cbind, out) ## undo the original splitting
+        ##out <- do.call(cbind, out) ## undo the original splitting
+        out <- unsplit(out, Block) ## undo the original splitting
     } else {
         ## if we have all.perms now then we must have generated it
         ## during checking or user passed it with control
@@ -48,17 +49,17 @@
     Pstrata <- getStrata(control, which = "plots", drop = TRUE)
     plotCTRL <- getPlots(control)
     typeP <- getType(control, which = "plots")
-    
+
     ## collect the within control object
     withinCTRL <- getWithin(control)
     typeW <- getType(control, which = "within")
-    
+
     n <- length(ind)
     sn <- seq_len(n)
-    
+
     ## result object
     Set <- matrix(nrow = nset, ncol = n)
-    
+
     ## if no strata at Plot level permute all samples using stated scheme
     if(is.null(Pstrata)) {
         ## If no strata at plot then permute all samples using stated scheme
@@ -82,7 +83,7 @@
         }
     } else {
         ## If strata at Plot level present, either permute samples, Plots or both
-        
+
         ## permute strata at Plot level?
         if(isTRUE(all.equal(typeP, "none"))) {
             Set[] <- rep(sn, each = nset)
@@ -97,16 +98,16 @@
                                         ncol = plotCTRL$ncol))
             }
         }
-        
+
         tmp <- Set
-        
+
         ## permute the samples within Plot strata
         if(!isTRUE(all.equal(typeW, "none"))) {
             for(i in seq_len(nset)) {
                 tab <- table(Pstrata[ind][Set[i,]])
                 ## the levels of the Plot strata
                 levs <- names(tab)
-                
+
                 ## same permutation within each level of the Plot strata?
                 if(withinCTRL$constant) {
                     if(isTRUE(all.equal(typeW, "free"))) {
@@ -123,7 +124,7 @@
                 } else {
                     start <- start.row <- start.col <- flip <- NULL
                 }
-                
+
                 ## for each level of strata, permute
                 for(lv in levs) {
                     ## must re-order strata here on basis of Ser as they

Modified: pkg/permute/inst/ChangeLog
===================================================================
--- pkg/permute/inst/ChangeLog	2013-11-06 13:18:19 UTC (rev 2659)
+++ pkg/permute/inst/ChangeLog	2013-11-06 17:14:29 UTC (rev 2660)
@@ -11,6 +11,10 @@
 	The `print` method for class "how" wasn't printing details of
 	mirroring or constant settings for within-plot components.
 
+	* shuffleSet: was incorrectly recombining individual block-level
+	permutations.
+	Reported by Jari Oksanen.
+
 	* numPerms: fixed a bug where `numPerms()` was ignoring Blocks when
 	computing the number of possible permutations.
 



More information about the Vegan-commits mailing list