[Vegan-commits] r1751 - pkg/permute/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 24 10:01:11 CEST 2011
Author: gsimpson
Date: 2011-08-24 10:01:10 +0200 (Wed, 24 Aug 2011)
New Revision: 1751
Modified:
pkg/permute/R/shuffle.R
Log:
safer use of seq_len for sequences instead of 1:n
Modified: pkg/permute/R/shuffle.R
===================================================================
--- pkg/permute/R/shuffle.R 2011-08-24 08:00:07 UTC (rev 1750)
+++ pkg/permute/R/shuffle.R 2011-08-24 08:01:10 UTC (rev 1751)
@@ -1,12 +1,10 @@
-`shuffle` <-
- function (n, control = permControl())
-{
+`shuffle` <- function (n, control = permControl()) {
## If no strata then permute all samples using stated scheme
if(is.null(control$strata)) {
out <-
switch(control$within$type,
"free" = shuffleFree(n, n),
- "series" = shuffleSeries(1:n,
+ "series" = shuffleSeries(seq_len(n),
mirror = control$within$mirror),
"grid" = shuffleGrid(nrow = control$within$nrow,
ncol = control$within$ncol,
@@ -18,9 +16,9 @@
## permute strata?
if(control$blocks$type == "none") {
- out <- 1:n
+ out <- seq_len(n)
} else {
- flip <- runif(1L) < 0.5
+ flip <- runif(1L) < 0.5 ## why are we doing this? Null better?
out <- shuffleStrata(control$strata,
type = control$blocks$type,
mirror = control$blocks$mirror,
More information about the Vegan-commits
mailing list