[Vegan-commits] r2682 - in pkg/permute: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Nov 9 02:56:28 CET 2013


Author: gsimpson
Date: 2013-11-09 02:56:28 +0100 (Sat, 09 Nov 2013)
New Revision: 2682

Modified:
   pkg/permute/R/allPerms.R
   pkg/permute/man/allPerms.Rd
Log:
remove args that are in how() object

Modified: pkg/permute/R/allPerms.R
===================================================================
--- pkg/permute/R/allPerms.R	2013-11-09 01:51:12 UTC (rev 2681)
+++ pkg/permute/R/allPerms.R	2013-11-09 01:56:28 UTC (rev 2682)
@@ -1,5 +1,4 @@
-`allPerms` <- function(n, control = how(), max = 9999,
-                       observed = FALSE) {
+`allPerms` <- function(n, control = how()) {
     ## start
     v <- n
     ## expand n if a numeric or integer vector of length 1
@@ -8,16 +7,20 @@
     ## number of observations in data
     n <- nobs(v)
     ## check permutation scheme and update control
-    pcheck <- check(v, control = control, make.all = FALSE)
+    make <- getMake(control)
+    pcheck <- check(v, control = update(control, make = FALSE))
     ## ctrl <- pcheck$control
+    ## if we do copy the new updated control, we need to update to
+    ## reset make
+    ## ctrl <- update(ctrl, make = make)
 
     ## get max number of permutations
     nperms <- numPerms(v, control = control)
 
     ## sanity check - don't let this run away to infinity
     ## esp with type = "free"
-    if(nperms > max)
-        stop("Number of possible permutations too large (> 'max')")
+    if(nperms > getMaxperm(control))
+        stop("Number of possible permutations too large (> 'maxperm')")
 
     WI <- getWithin(control)
     strataP <- getStrata(control, which = "plots")
@@ -55,13 +58,14 @@
     ## bind all the blocks together
     out <- do.call(rbind, out) ## hmm are any of these the same shape?
 
-    if(!observed) {
+    if(!(observed <- getObserved(control))) {
         obs.v <- seq_len(n)
         obs.row <- apply(out, 1, function(x, obs.v) all(x == obs.v), obs.v)
         out <- out[!obs.row, ]
         ## reduce the number of permutations to get rid of the
         ## observed ordering
-        control$nperm <- control$nperm - 1
+        ##control$nperm <- control$nperm - 1
+        control <- update(control, nperm = getNperm(control) - 1)
     }
     class(out) <- "allPerms"
     attr(out, "control") <- control

Modified: pkg/permute/man/allPerms.Rd
===================================================================
--- pkg/permute/man/allPerms.Rd	2013-11-09 01:51:12 UTC (rev 2681)
+++ pkg/permute/man/allPerms.Rd	2013-11-09 01:56:28 UTC (rev 2682)
@@ -10,8 +10,7 @@
   permutations for a given R object and a specified permutation design.
 }
 \usage{
-allPerms(n, control = how(), max = 9999,
-         observed = FALSE)
+allPerms(n, control = how())
 
 \method{summary}{allPerms}(object, \dots)
 }
@@ -21,11 +20,6 @@
   \item{control}{a list of control values describing properties of the
     permutation design, as returned by a call to
     \code{\link{how}}.}
-  \item{max}{the maximum number of permutations, below which complete
-    enumeration will be attempted. See Details.}
-  \item{observed}{logical, should the observed ordering of samples be
-    returned as part of the complete enumeration? Default is
-    \code{FALSE} to facilitate usage in higher level functions.}
   \item{object}{an object of class \code{"allPerms"}.}
   \item{\dots}{arguments to other methods.}
 }
@@ -45,7 +39,7 @@
   possible permutations would also become problematic in such cases. To
   control this and guard against trying to evaluate too large a number
   of permutations, if the number of possible permutations is larger than
-  \code{max}, \code{allPerms} exits with an error.
+  \code{getMaxperm(control)}, \code{allPerms} exits with an error.
 }
 \value{
   For \code{allPerms}, and object of class \code{"allPerms"}, a matrix
@@ -79,14 +73,14 @@
             plots = Plots(strata = fac))
 Nobs <- length(fac)
 numPerms(seq_len(Nobs), control = ctrl) ## 6
-(tmp <- allPerms(Nobs, control = ctrl, observed = TRUE))
+(tmp <- allPerms(Nobs, control = update(ctrl, observed = TRUE)))
 (tmp2 <- allPerms(Nobs, control = ctrl))
 
 ## turn on mirroring
 ##ctrl$within$mirror <- TRUE
 ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE))
 numPerms(seq_len(Nobs), control = ctrl)
-(tmp3 <- allPerms(Nobs, control = ctrl, observed = TRUE))
+(tmp3 <- allPerms(Nobs, control = update(ctrl, observed = TRUE)))
 (tmp4 <- allPerms(Nobs, control = ctrl))
 
 ## prints out details of the permutation scheme as



More information about the Vegan-commits mailing list