[Vegan-commits] r266 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 19 14:34:19 CET 2008


Author: gsimpson
Date: 2008-03-19 14:34:19 +0100 (Wed, 19 Mar 2008)
New Revision: 266

Modified:
   pkg/R/permuted.index2.R
Log:
Fixes a bug when permuting levels of 'strata'; was shuffling the samples within strata also

Modified: pkg/R/permuted.index2.R
===================================================================
--- pkg/R/permuted.index2.R	2008-03-19 13:33:17 UTC (rev 265)
+++ pkg/R/permuted.index2.R	2008-03-19 13:34:19 UTC (rev 266)
@@ -6,7 +6,8 @@
         {
             lev <- length(levels(strata))
             ngr <- length(strata) / lev
-            rep(sample(lev), ngr) + (rep(seq(0, ngr-1), each = lev) * lev)
+            sp <- split(seq(along = strata), strata)
+            unname(do.call(c, sp[.Internal(sample(lev, lev, FALSE, NULL))]))
         }
     `permuted.grid` <-
         function(nrow, ncol, mirror = FALSE, start.row = NULL, start.col = NULL)



More information about the Vegan-commits mailing list